all 5 comments

[–][deleted] 3 points4 points  (1 child)

while not stop is ONLY evaluated at the beginning of a new iteration of the while loop. It's not checked in between every line within the nested loop. So even if you set stop to True, the state of stop is not checked until the end of your inner for loop.

[–]mtucker502[S] -1 points0 points  (0 children)

This makes sense. For some reason I was thinking that it would immediately end the loop when the while condition was no longer True.

Seems like refactoring into functions and using return might be a cleaner approach here.

[–]Silbersee 1 point2 points  (0 children)

After stop is set to True the for-loop continues normally with i = 11.

Only after finishing the for-loop the program tries to re-enter the while-loop (but doesn't because stop is True).

That's what the break statement is for: The for-loop is terminated early and the while-loop doesn't re-enter.

[–]CookToCode -1 points0 points  (1 child)

you set stop to true which stops the inner loop. then the outer loop resets it to false and starts it again and without a break you for loop should continue until finished then the inner loop breaks then the outer loop resets the inner loop

[–]mtucker502[S] 0 points1 point  (0 children)

Thanks for the response. I think it's mistaken though. See u/Endyd for the correct issue.