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 trialNigel Poolena90
328 PointsI'm not sure how to complete the stage five challenge
i did.. def add_list(): but I'm not sure where to go from here
# 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():
for num in add_list:
return num
3 Answers
Perry Stripling
20,210 PointsThe instructions appear to want a routine called [summarize] that calls [add_list] and prints out the result in the prescribed manner. [add_list] should sum the list it is given as an argument and return that number. In this case, to [summarize] for display (print).
michaelangelo owildeberry
18,173 PointsWhat did you pass into add_list function? =)
Perry Stripling
20,210 Pointsa 'list', like this: [1, 2, 3]
that and Result is what is reported by Summarize.
michaelangelo owildeberry
18,173 PointsI passed it through this way =)
def add_list(numbers):
Perry Stripling
20,210 Pointsthen var s/be setup -
numbers = [1, 2, 3]
- before doing so. Also, note that add_list should go thru numbers and sum; like -
tot = 0 for number in numbers tot = tot + number return tot
thus, you call summarize, which calls add_list.