Nearby lessons
54 of 108Python - 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
breakimmediately terminates the loop.continueskips only the current iteration.passperforms no action.passis mainly used for empty functions, classes, loops, and conditional blocks.breakandcontinuecan be used only inside loops.passcan be used anywhere a statement is required.
🧠 Test Your Knowledge
3 QuestionsProgress: 0 / 3
Keep Going!Python - Del None Statement