Whats wrong with my code?


#1



Replace this line with your code. 
n = [3, 5, 7]
def total(numbers):
    result=0
    for x in numbers:
        result+=x
        return result
print total(n)


#2

a function ends the moment a return keyword is reached, which in your case happens in the first run of the loop, you might want to change the intend of return so your whole for loop can run


#3

Thank you so much !
Had the same doubt


#4

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.