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

Neel Patel
Neel Patel
5,216 Points

Unable to understand "python functions" challenge.

Hi, I am not able to understand challenge -

"Make a function named add_list that adds all of the items in a passed-in list together and returns the total. Assume the list contains only numbers. You'll probably want to use a FOR loop."

However I'm not sure what is the name of list? Can I create a new list and pass on to function?

Please explain.

4 Answers

Hi Neel

Basically you have got to pass a array as a argument to a function named add_list

def add_list(my_list):
    total=0

    for num in my_list:

        total=total+num

    return total


new_list=[1,2,3]
print(add_list(new_list))

try this

Kenneth Love
STAFF
Kenneth Love
Treehouse Guest Teacher

The name you give to your arguments doesn't matter except to you. Make it something that makes sense to you so it'll be easier to work with.

This confused the crap out of me too, although I understood what you were getting at. I think it's a badly phrased question and should be rewritten.

Kenneth Love
STAFF
Kenneth Love
Treehouse Guest Teacher

I've updated the prompt a bit to try and make it more clear. Thanks for bringing it up!