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 trialDeborah Millians
553 Pointsmissing how I define the function as the sum of the numbers in a list
I have watched the lesson video three times and do not understand what I am supposed to write. Beginner problems from a beginner.
# 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(sum 1,2,3)
4 Answers
Farrah Dickerson
10,173 Pointsdef add_list(user_defined_list):
return "The sum of {} is {}".format(user_defined_list, sum(user_defined_list))
Deborah Millians
553 PointsThank you! I was making it too hard for the second portion of the challenge.
Deborah Millians
553 PointsThank you both. Caleb's answer helped with the first problem. But I did get the "tuples" error for the second problem. Continuing to work second part...
Caleb Kleveter
Treehouse Moderator 37,862 PointsGood to know. If I remember correctly you don't add the string in the first task. Am I right? Deborah, try changing the tuple to a list as Farrah said .
Caleb Kleveter
Treehouse Moderator 37,862 PointsDoes this work?
a_list = (1,2,3)
def add_list(a_list):
output = sum(a_list)
return output
Farrah Dickerson
10,173 PointsFarrah Dickerson
10,173 PointsYou've got a lot going on there:
I hope that helps.