Nearby lessons
51 of 159Python - Pass Statement
📌 What You Will Learn
- Define the pass statement and what it does
- Explain why pass is required when Python does not allow empty blocks
- Use pass as a placeholder inside if blocks, loops and functions
- Compare pass with break
- Compare pass with continue
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
Example 2 - pass inside Loop
Example 3 - Empty Function
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. |
📝 Key Takeaways
- The pass statement does nothing and acts as a placeholder
- Python does not allow an empty block, so pass is used as a filler
- pass can be used anywhere a statement is required
- break stops a loop while pass does nothing
- continue skips the current iteration while pass does nothing
🧠 Test Your Knowledge
3 QuestionsProgress: 0 / 3