Navigation:
Break Statements
You learned earlier that for loops and while loops keep iterating over a sequence until it reaches the end or until a condition is met.
There is another way to stop running these loops before the end of the list or before a condition is met.
You can do this with the break statement. This lets you break out of the loop in either a for loop or while loop.
Here’s an example with a while loop: