Lists and Functions 15/18 Conundrum!


#1



https://www.codecademy.com/courses/python-beginner-nzzVa/3/4?curriculum_id=4f89dab3d788890003000096

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)


#2

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


#3

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


#4

Thank you :grinning: