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 trialOmri Zachay
472 PointsFunction error
Hi,
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)
thanks
1 Answer
Ken Alger
Treehouse TeacherOmri;
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,
Ken
Ken Alger
Treehouse TeacherKen Alger
Treehouse TeacherEdited for markdown