Python break Keyword
Example
End the loop if i is larger than 3:
for i in range(9):
if i > 3:
break
print(i)
Run example »
Definition and Usage
The break
keyword is used to break out a
for
loop, or a while
loop.
More Examples
Related Pages
Use the continue
keyword to end the current iteration in a loop, but continue with the next.
Read more about for loops in our Python For Loops Tutorial.
Read more about while loops in our Python While Loops Tutorial.