Here is my conundrum.Imagine you have a loop and a list with 100 members in python like the following:
myList=range(100)
for i in range(100):
print(myList[i])
print(myList[i+5])
print(myList[i-5])
How would one prevent the index of myList from exceeding the length of the list or going under 0?
For example, if the index in the loop was 99 then:
print(myList[i+5])
would return an index error.
To clarify, I mean so that I could find out what [i+5] as if the list was on a loop.
So if you imagine that the index was 99 (again) I would like to go to the 4th index (after adding 5 and looping back to the start).
5and end before the length - 5?