Lists and Functions 15/18 Conundrum!


The error message, "Oops, try again. total([0, 3, 6]) returned 0 instead of 9", frustratingly pops up, but, even after swapping 'x' with both 'numbers' and 'no' (worth a try), I still get no respite...

I expected it to work... I even looked at some archived forums on this topic and followed their format for the answer... NO LUCK!

n = [3, 5, 7]

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


i think you just added (tab/indentation) before return result , so remove indentation
because in your code return is inside for loop !!


Make sure return result is on the same line as the for loop. :stuck_out_tongue_winking_eye:


Thank you :grinning: