Is there some way to move the index forward in a for loop in python? For example, if I'm iterating through a string and find some char that I'm looking for, can I begin reading from that position on the next iteration of the for loop?
Like, after reading an x, read until a y and start from the position following the y on the next iteration:
for i in range(len(myString)):
if myString[i] == 'x':
j = i + 1
while( myString[j] != '\n' ):
if( myString[j] == 'y' ):
i = j + 1 # start at position following y in string on the next iteration
j = j + 1
Or do I have to use a while loop to achieve this?
whileloop, or use the keywordcontinuein the case that you want to ignore.