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 trialNichelle Segar
9,857 PointsTypeError: add_list() missing 2 required positional arguments: 'y' and 'z'
Still working on the challenge question, but now getting the error listed above. It works when I plug it into the console, though.
def add_list(x, y, z): return(x+y+z)
add_list(1, 2, 3)
6
def add_list(x, y, z):
return(x+y+z)
add_list(1, 2, 3)
# 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.
2 Answers
Mario Blokland
19,750 PointsHi Nichelle Segar,
what you want to do is to automate the function. Imagine you had 1000 numbers like this and had to return the sum. Wow :D
You want to take a list in an argument like this:
def add_list(list_of_numbers):
# some variable which holds the sum
# for loop
# add numbers from the list to the variable which holds the sum
# return the sum
you will need to create a for loop and within the loop add the numbers. I don't want to say too much because this way you won't learn as good as you could. Learning from problems you have and find the solution with hints yourself is most rewarding. If you don't know how to create a for loop I would suggest to go a few videos back and look up where Kenneth explains for loops.
Nichelle Segar
9,857 PointsOk, thanks.
Mario Blokland
19,750 PointsYou are welcome. If something was unclear just ask again :-)