Описание тега break
A break statement is a flow-control feature provided by most programming languages that allows for an early exit from a loop; once a break statement is reached, its enclosing loop is immediately exited.
Using break
will immediately exit the loop without completing the current iteration, in this example when i
is 3
the loop will finish without any other line in the loop being executed.
Example (Python):
for i in range(1, 6):
print(i)
if i == 3:
break
print("do stuff")
print("after the loop")
Output:
1
do stuff
2
do stuff
3
after the loop
For more information see loops