15. Iterating over a list in a function ("reslut not defined")


If you have problem with "reslut is not defined"
Maybe this is a bug or I have done something wrong.


#This is working
n = [3, 5, 7]

def total(x):
    reslut = 0
    for i in range(0, len(x)):
        reslut = reslut + x[i]
    return reslut
print total(n)


n = [3, 5, 7]

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


check your spelling


You beat me to it, again, in the first return result is indeed misspelled


My secret is to make my replies shorter and more vague.


No more code for me today.. Thanks and have a nice day! xD