Skip to main content

Python pass Statement

pass Statement

Python pass statement is a null statement: nothing happens when it is executed.

When executing code that contains a pass statement, the Python interpreter treats the pass statement as a single statement. As a result, it does not issue a syntax error.

pass statement with if statement

The pass statement can be used in if statement:

if condition:
pass

pass statement with for and while loop

The pass statement can be used in for loops:

for i in range(1,100):
pass

and in while loops:

while condition: 
pass

pass statement with functions and classes

The pass statement can be used in functions:

def foo():
pass

and in classes:

class BarClass:
pass