Python GLOSS
The break Statement
With the break statement we can stop the loop even if the while condition is true:
ExampleGet your own Python Server
Exit the loop when i is 3:
i = 1
while i < 6:
print(i)
if i == 3:
break
i += 1
Try it Yourself »