Length of a list/array/etc is not a valid index for that object. Because it is 0 indexed you at a minimum need to subtract 1 from the length. Range syntax and usage is valid. Max value of range(n) is n-1.
Wasn’t stating it was an issue with the range. Was stating it’s an issue with their usage of n. I see how that could’ve been more clear in my first comment.
3
u/earchip94 Aug 17 '25 edited Aug 18 '25
Length of a list/array/etc is not a valid index for that object. Because it is 0 indexed you at a minimum need to subtract 1 from the length. Range syntax and usage is valid. Max value of range(n) is n-1.
Edited for clarity.