Concept Flow - Pass statement usage
Start
Encounter pass
Do nothing, skip
Continue execution
End
The pass statement is a placeholder that does nothing and lets the program continue without error.
for i in range(3): if i == 1: pass else: print(i)
| Iteration | i | Condition i==1 | Action | Output |
|---|---|---|---|---|
| 1 | 0 | False | print(0) | 0 |
| 2 | 1 | True | pass (do nothing) | |
| 3 | 2 | False | print(2) | 2 |
| - | - | - | Loop ends after i=2 | - |
| Variable | Start | After 1 | After 2 | After 3 | Final |
|---|---|---|---|---|---|
| i | - | 0 | 1 | 2 | Loop ends |
pass statement: - Does nothing, acts as a placeholder - Used where syntax requires a statement - Does not affect program flow - Common in empty loops, functions, or conditionals - Helps avoid syntax errors