Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

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!