In this tutorial it says that using either method is okay but, using Method 1 did not work.
Why is using
range() here preferable than calling the list itself?
For instance, Method 2 which is this
for i in range(0, len(numbers)):
over Method 1 which is this
for i in numbers:
When I use Method 1 the error shows as:
list index out of range.
This was the full one I wrote in case you were wondering:
n = [3, 5, 7] def total(numbers): result = 0 for i in numbers: result += numbers[i] return result total(n)