Nearby lessons

54 of 108

Python - Pass Statement

pass Statement

The pass statement does nothing.

It is used as a placeholder where Python expects a statement.

Why pass is Required?

Sometimes we plan to write code later.

Since Python does not allow an empty block, we use the pass statement.

Example 1 - pass Statement

🐍
main.py
Python 3 Runtime
Loading Editor...
Output Preview
Program Completed

Example 2 - pass inside Loop

🐍
main.py
Python 3 Runtime
Loading Editor...
Output Preview
Loop Completed

Example 3 - Empty Function

🐍
main.py
Python 3 Runtime
Loading Editor...
Output Preview
Function Created Successfully

Difference Between break and pass

break pass
Stops the loop. Does nothing.
Changes program execution. Acts as a placeholder.

Difference Between continue and pass

continue pass
Skips the current iteration. Does nothing.
Works only inside loops. Can be used anywhere a statement is required.

Comparison of Transfer Statements

Statement Purpose
break Terminates the loop immediately.
continue Skips the current iteration.
pass Placeholder statement that performs no action.

Important Notes

  • break immediately terminates the loop.
  • continue skips only the current iteration.
  • pass performs no action.
  • pass is mainly used for empty functions, classes, loops, and conditional blocks.
  • break and continue can be used only inside loops.
  • pass can be used anywhere a statement is required.

🧠 Test Your Knowledge

3 Questions

Progress: 0 / 3
Keep Going!Python - Del None Statement