What is the Pass Statement in Python for Loop?

In this tutorial, we will learn what is the pass statement in Python for Loop with the help of examples? By Pankaj Singh Last updated : April 13, 2023

The pass Statement

The pass is a type of null operation or null statement, when it executes nothing happens. It is used when you want do not want to write any code/statement to execute but syntactically a statement is required.

The pass Statement Examples

Practice the following program to learn the concept of the 'pass' statement in Python for Loops.

Example 1

Here, we are using "pass" statement in the function hello() definition - there is no statement in the function and if we do not use "pass", there will be an error.

def hello():
    pass

hello()

Example 2

for i in range(1,11):
    if(i==6):
        continue
    else:
        pass
    print(i)

Output

1
2
3
4
5
7
8
9
10

To understand the above programs, you should have the basic knowledge of the following Python topics:

Python Basic Programs »

Related Programs

Comments and Discussions!

Load comments ↻





Copyright © 2024 www.includehelp.com. All rights reserved.