The break statement in Python is used to exit a loop prematurely. When the interpreter encounters a break statement in a loop, it immediately exits the loop, regardless of whether the loop's condition is still evaluatable.
Here's an example of using break in a for loop:
main.py102 chars7 lines
In this example, when the loop encounters the number 3, the break statement is executed and the loop is terminated, not printing any numbers after 3.
gistlibby LogSnag