Break Statement in Python

Updated: May 18


The break statement is used to terminate the loop when a certain condition is gathering. The break statement is usually used inside a loop along with a if statement so that when a exacting condition returns true, the break statement is encountered and the loop terminates.

Syntax:

break

Flow Chart:



Example:

Program to display all the elements before number 70

for n in [11, 70, 88, 10, 90, 3, 7]:

print(n)

if(n==70):

print("The number 70 is found")

print("Terminating the loop")

break

Output:

11

70

The number 70 is found

Terminating the loop



Recent Posts

See All

Python Modules

A module is a file containing Python definitions and statements. A module can characterize functions, classes and variables. A module can likewise incorporate runnable code. Gathering related code int

Command Line Arguments in Python

Command Line Arguments are the arguments that are specified after the name of the program in the command line shell of the operating system. Python gives different ways of dealing with these types of