Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Python Python Basics (Retired) Putting the "Fun" Back in "Function" Functions

What am I doing wrong here?

Here is what I have so far

ex_list = [1,2,3]

def add_list(ex_list):
  sum = 0
  for num in ex_list:
    sum += num 
  return sum 

print(add_list(ex_list))

def summarize(sum):
  return("The sum of {} is {}".format(sum, add_list(sum))

2 Answers

Joseph Kato
Joseph Kato
35,340 Points

Hi Adrian,

It looks like two very minor issues:

  1. Your return statement is missing a closing parenthesis (note: you don't actually need parentheses around the return statement).

  2. "The sum of {} is {}" needs a period at the end.

Kenneth Love
STAFF
Kenneth Love
Treehouse Guest Teacher

When I run this against the code challenge, I get a syntax error because you're halfway using return like a function. Once that's cleaned up (remove the (), the first step passes. The second step fails because the string is slightly wrong.