+ 2
How to stop while loop function in python?
5 Réponses
+ 4
I assume that you are asking about breaking out of a loop, use break then
Eg: https://code.sololearn.com/cNJ1pgorRryB/?ref=app
+ 2
x = 5
while x > 0
x = x - 1
After counting down 5 4 3 2 1 the loop stops. Additionally you could say:
while x > 0
if x == 2
break
And the code will exit the loop early