Break Statement

Break statement in Python 3:

The break statement is used for premature termination of the current loop. After abandoning the loop, execution at the next statement is resumed, just like the traditional break statement in C.

The most common use of break is when some external condition is triggered requiring a hasty exit from a loop. The break statement can be used in both while and for loops.

If you are using nested loops, the break statement stops the execution of the innermost loop and starts executing the next line of the code after the block.

Syntax:

break




The following program demonstrates the use of break in a for loop iterating over a list.

User inputs a number, which is searched in the list. If it is found, then the loop terminates with the 'found' message.