Iterating over a list in a function


Hi, below is the error I'm getting for this exercise:
Oops, try again. total([0, 3, 6]) returned 6 instead of 9

My code is below:

Any help would be appreciated! Thanks!

n = [3, 5, 7]

def total(numbers):
    result = 0
    for i in range(len(numbers)):
        print numbers[i]
        result =+ numbers[i]
    return result
print total(n)


the shorthand you use should be +=, not =+


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