Not returning correctly?


when i run this

n = [3, 5, 7]

def total(numbers):
result = 0
for i in range(len(numbers)):
result += i

return result

Oops, try again. total([0, 3, 6]) returned 3 instead of 9

what do i need to fix


What your code does here:

you have 3 elements in the list, so len(numbers) is 3, then you go from 0 to 2 (->range(3)) and then add 1 for each round.


for i in numbers:

so you add each element in the list to result