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

Python Function Help

I need to create a function named add_list([1, 2, 3]) et its should return 6. summarize([1, 2, 3]) should return "The sum of [1, 2, 3] is 6."

Help plz

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.

1 Answer

So the add_list function should take a list as a parameter, loop through that list and add each value/number to a total (which should start with a value of zero), then return that total.

The summarize function should also take a list as a parameter, pass that list into the add_list function, and then return a string with the text formatted with the list and the result of the add_list function.

You haven't included any code that you've tried to use, so I can't help with any typos or syntax errors. I suggest you give it a go, and if you're still having trouble, try watching the videos again, maybe pause it and follow along as best as you can.

Good luck!