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 trial

Python Python Basics (Retired) Putting the "Fun" Back in "Function" Functions

Nigel Poolena90
Nigel Poolena90
328 Points

I'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

functions.py
# 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

The 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).

What did you pass into add_list function? =)

a 'list', like this: [1, 2, 3]

that and Result is what is reported by Summarize.

I passed it through this way =)

def add_list(numbers):

then 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.