Lesson 10
pass Statement — Placeholder for Empty Blocks
Use Python pass as a null statement in if, else, for, and while blocks. Keep syntax valid when a block is intentionally empty.
Beginner15 min
pass statement
passis a keyword.passinstructs the Python compiler and PVM to ignore the indentation block — bypass it without doing anything.
Use pass when syntax requires a block but you have nothing to execute yet (stub code, placeholders).
Syntax examples
if test_cond:
passif test_cond:
pass
else:
passfor varname in iterable_object:
passwhile test_cond:
passpass vs continue vs break
| Keyword | Meaning |
|---|---|
pass |
Do nothing — block is intentionally empty |
continue |
Skip to next loop iteration |
break |
Exit loop entirely |
return statement
return is also a transfer statement, but it belongs to functions. It is explained in the Functions module.
Next: File 11 — Nested Loops
Loading playground…