Python Pass Statement

The pass statement is a placeholder that does nothing. It is used when a statement is syntactically required but no action is needed.

 

Example: Using Pass in a Loop

 

for num in range(5):
    if num == 2:
        pass  # Placeholder for future code
    else:
        print(num)

Try It Now

Example: Using Pass in a Function

def my_function():
    pass  # Function not implemented yet

Try It Now

Key Differences Between Break, Continue & Pass

  • break – Exits the loop completely.
  • continue – Skips the rest of the current iteration and proceeds to the next.
  • pass – Does nothing; acts as a placeholder.