Slicing up to 15 items after a certain item in a python list
I'm trying loop through a list in python and compare each element in the list to the next 15 elements in the list. I want something like the following code, but I don't know how to say it in python. Also, I want to do it without importing anything extra.
for i in S: for j in S[i: '''up 15 elements after i or however much is left if less than 15'''] #do some comparisons
So basically, for the inside loop, I only want to iterate from item i to item i+15 (or whatever is left), without importing iterator or such.
Use an index:
for index, i in enumerate(S): for j in S[index+1:index+16] #do some comparisons