A bit more explaining: Arr=["a","b","c"] So a location is 0 And b location is 1 And c location is 2 However array length is 3
Now when I am looping through an array with the in range command I get 1, 2, 3 but there is no position 3 in the array ( out of something error) and I am also not getting the first element of the array that is on location 0
That is why you might encounter n-1 in other people's code and you can use it yourself also in your code
In conclusion: if n is 1 print(Arr[n-1]) would give me an array element that is in position of 0 and would print a, and so on
1
u/Wrong-Bit8534 Aug 17 '25
Array starts from 0, try n-1