MWZ

MINDWAREZONE

Pass Statement in python

  • The pass statement is a null operation in Python.
  • It does nothing when executed.
  • It is used as a placeholder where code is required syntactically but no action is needed yet.
  • Commonly used in empty functions, loops, classes, and conditional statements.

Example 1: Pass in an if Statement

num = 10 

if num > 5: 
    pass 
    print("Program continues")
            

Output

Program continues
            

Example 2: Pass in a Function

def my_function(): 
    pass 
    print("Function created successfully")
            

Output

Function created successfully