I'm typing in this code verbatim for a class, but it's not working. I'm using Python3.7. It never moves past the first argument. What is wrong?
#function with variable number of arguments
def multi_add(*args):
result = 0
for x in args:
result = result + x
return result
print (multi_add(10, 4, 5))
I think your return result
has incorrect indentation. As it is i would expect it to return after first arg, wheras if it were one indent left it would return after forloop completes.