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

Alperen Guman
Alperen Guman
6,552 Points

How do you complete this challange?

You can find my code attached. When I do task 2, it says task 1 is no longer passing. I don't understand what the problem is the least bit.

functions.py
# add_list([1, 2, 3]) should return 6
# summarize([1, 2, 3]) should return "The sum of [1, 2, 3] is 6."
# Note: both functions will only take *one* argument each.

def add_list(something):
  return sum(something)

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

1 Answer

Dan Johnson
Dan Johnson
40,532 Points

You'll want to drop the call to print and just return the formatted string. print doesn't return any value.

Alperen Guman
Alperen Guman
6,552 Points

I have tried that previously with no luck. I'll drop it again. While call to print is a problem it doesn't seem to be the main problem here.

Dan Johnson
Dan Johnson
40,532 Points

Looks like you were missing an extra parenthesis. format and sum were closed but not print so maybe the mismatch remained after you dropped it the first time.

I checked it again to be sure and this passed:

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