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

Issue with Python: Functions Code Challenge Step 2

Question asks:

Now, make a function named summarize that also takes a list. It should return the string "The sum of X is Y.", replacing "X" with the string version of the list and "Y" with the sum total of the list.

I am also pasting answer to step 1 as it relates:

def add_list(list):
  sum = 0
  for item in list:
    sum += item
  return sum

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

I am not certain what I am doing incorrectly. Any advice would be appreciated.

1 Answer

You should return the string, not print it.