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 trialAaron Williams
1,702 PointsHow do I do this? Python basics stage 5
I have no clue how to do this
# 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.
2 Answers
William Li
Courses Plus Student 26,868 PointsHere's a simple way to implement add_list
def add_list(li):
result = 0
for i in li:
result += i
return result
I'll leave it to you to figure out the summarize
function, HINT:just make use of the add_list
function.
shezazr
8,275 Pointsthe hints tell you what to do..
a function that accepts a list and returns a sum (this involves loop)
summarize accepts a list and returns in text (hint: use the previous function in this one to get the sum)