---Advertisement---

Python Break, Continue, and Pass Statements Explained with Examples Great 2025

By Bhavani

Updated On:

---Advertisement---
Python Break, Continue, and Pass Statements

Python’s loop control statements โ€” break, continue, pass โ€” are essential for modifying the flow of loops like for and while. Let’s explore each statement with practical examples.


The break statement is used to terminate the loop immediately when a specific condition is met.

python

my_list = [‘Siya’, ‘Tiya’, ‘Software Moji’, ‘Daksh’, ‘Riya’]

for name in my_list:

    print(name)

    if name == ‘Software Moji’:

        print(‘Found the name Software Moji’)

        break

print(‘Loop is Terminated’)

pgsql

Siya  

Tiya  

Software Moji  

Found the name Software Moji  

Loop is Terminated  

python

my_list = [‘Siya’, ‘Tiya’, ‘Software Moji’, ‘Daksh’, ‘Riya’]

i = 0

while i < len(my_list):

    print(my_list[i])

    if my_list[i] == ‘Software Moji’:

        print(‘Found the name Software Moji’)

        break

    i += 1

print(‘After while-loop exit’)

pgsql

Siya  

Tiya  

Software Moji  

Found the name Software Moji  

After while-loop exit  


The continue statement skips the remaining code in the current iteration and moves to the next iteration.

python

for i in range(10):

    if i == 7:

        continue

    print(“The Number is:”, i)

python

The Number is: 0  

The Number is: 1  

… 

The Number is: 6  

The Number is: 8  

The Number is: 9  

python

i = 0

while i <= 10:

    if i == 7:

        i += 1

        continue

    print(“The Number is:”, i)

    i += 1

python

The Number is: 0  

The Number is: 1  

… 

The Number is: 6  

The Number is: 8  

… 


The pass statement is used as a placeholder for future code. It does nothing when executed.

python

def my_function():

    pass

python

for i in range(5):

    if i == 3:

        pass

    print(i)


โœ… Use break to terminate a loop immediately.
โœ… Use continue to skip the current iteration and move to the next one.
โœ… Use pass as a placeholder for code you intend to implement later.

Python For & While Loops

Download Python

Leave a Comment

Index