Reputation: 3
I am parsing through data in a for loop. When the item is found, it kicks to a while loop and finds an item related to it. Within this while loop, I have a counter for the iterations within the while loop. When I kick back to the For loop, it wants to iterate from the original position of the For loop. I am trying to skip those iterations and start equal to the counter.
I am new to SO. If I was not clear enough, I would be happy to answer any questions.
for x in range(0, 10):
if b has been found
x = counter
#find a
#flag is true
while flag true:
#find b
#flag is false
#count iterations
Upvotes: 0
Views: 123
Reputation: 325
Would you be willing to restructure your code? I think the outer for loop would work better as a while loop:
x = 0
while x < 10:
if b has been found
x = counter
#find a
#flag is true
while flag true:
#find b
#flag is false
#count iterations
x += 1
That way, you can change the value of x in the loop.
Upvotes: 2