I'm facing an issue trying to sum all the elements of a list in python without using the sum() function. So, the thing is, when i run my code i'm able to get the desired result, but below appears this error
IndexError: list index out of range
This is my code:
numbers = [4,8,3,1,-3,3,-5,1,2,-8]
sum = numbers[0]
i = 0
for number in numbers:
i = i + 1
sum = sum + numbers[i]
print(sum)
According to the error message, the problem is in line 6, but i don't understand what's the problem. If anyone could help me, i'll appreciate it.