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 trialSam Lozier
9,699 PointsIn the python basics functions quiz, i'm getting a positional argument error, yet my code works on my computer.
What am I doing wrong?
# 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.
list = [1,2,3]
def add_list():
output = sum(list)
print("the sum of {} is {}".format(list,output))
add_list()
2 Answers
Hanley Chan
27,771 PointsHi,
You have the right idea, but the add_list function is suppose to take in the list as an argument. The list [1,2,3] is just an example.
Also it asks that the function simply to return the result. No need to print anything.
This worked for me
def add_list(a_list):
output = sum(a_list)
return output
Sam Lozier
9,699 Pointsthanks!
Matthew Rigdon
8,223 PointsMatthew Rigdon
8,223 PointsThis ^ The biggest thing to note is that every you are trying to use a value from a function, you want to use the return command.