Skip to main content

Section 7.4 break and continue

In loops, we sometimes want to traverse until we reach a certain value. We could make a loop condition with a boolean that is toggled as True once we reach that value, but there’s an easier way: the break statement.
When a break statement is reached, the loop immediately ends and proceeds with the code after the loop. break is only a valid statement inside of loops, such as the following:
The continue statement is another keyword that we can use in loops. When a continue statement is reached, the current iteration is stopped (similar to break), however, the loop will continue running for all iterations after the current one.

Note 7.4.1.

breakcontinue5continue5
You have attempted of activities on this page.