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!
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
Michael Nickey
Courses Plus Student 13,524 PointsIt should return the string "The sum of X is Y.", replacing "X" with the string version of the list and "Y" with the sum
What is wrong with this code? I see in the interpreter that I am getting an INT but it's expecting a string. Doesn't join() make this into a string by default?
def add_list(my_list):
sum = 0
for _ in my_list:
sum += _
return sum
def summarize(list_two):
list_sum = add_list(list_two)
string_list = ' '.join(list_two)
return "The sum of {} is {}".format(str(string_list), list_sum)
print(summarize([1,2,3]))
2 Answers

James Andrews
7,245 PointsThis is what I used to pass the challenge
def add_list(numbers):
total = 0;
for number in numbers:
total = total + number
return total
def summarize(numbers):
return "The sum of {} is {}.".format(numbers, add_list(numbers))
[Edit] sorry what I ended with was the return on the 2nd function I just hadn't changed it in my work file.
Michael Nickey
Courses Plus Student 13,524 PointsThanks, that helped a lot.

James Andrews
7,245 Pointscool can you make it "best answer"?
Kenneth Love
Treehouse Guest TeacherKenneth Love
Treehouse Guest Teacherstring_list = ' '.join(list_two)
is throwing the error becauselist_two
contains numbers, which can't be joined into a string without converting them to strings first. Try taking that line out completely, and change yourformat()
to only uselist_two
andlist_sum
, and see what happens.