breaking while loops
In python, you can use the break statement:
while True: if 1 == 2: break print('I does not equal 2')
Please mark this as the correct answer thanks!
@KianAlford like others had suggested, break at different loops. You could use controlled variables. e.g. isAlive = true
- while isAlive and doSomething
#to break, set isAlive = false then use break statement
#if necessary, use if !isAlive: break immediately after the while loop if you
#to prevent codes not inside the loop from running
You try using a flag variable(like concept ) like just make it true whenever you want to break a loop and that flag variable gets checked for each iteration. I think it might help.