Skip to main content
MahiDev — Learn. Build. Become AI-ready.

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

  • pass is a keyword.
  • pass instructs 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

python
if test_cond:
    pass
python
if test_cond:
    pass
else:
    pass
python
for varname in iterable_object:
    pass
python
while test_cond:
    pass

pass 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…