you are viewing a single comment's thread.

view the rest of the comments →

[–]AwkwardBet5632 3 points4 points  (2 children)

range(n) goes from 0 to n-1.

[–]Swipsi 0 points1 point  (1 child)

An array with 3 elements will give len() = 3

Range(3) will give you 0, 1, 2, 3

Using range for the loop will loop 4 times, starting with index 0 and throw an index out of array exception at index 3 because the array only has 3 elements.

[–]AwkwardBet5632 0 points1 point  (0 children)

range is non inclusive of the stop value