Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

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

Function error


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.

What is wrong with my code ?

def summarize(a_list):
  total = 0
  for item in a_list:
    total = total + item
    print (the sum of a_list is total)


Ken Alger
Ken Alger
Treehouse Teacher

Edited for markdown

1 Answer

Ken Alger
Ken Alger
Treehouse Teacher


Welcome to Treehouse!

Your function isn't returning the string as the challenge directions state. You will probably want to use the .format() method for this challenge in the return statement.

Post back if you are still stuck.

Happy coding,