Python pass
pass is a null operation. It does nothing and is used as a placeholder where Python expects a statement but you haven't written the logic yet.
pass in an if Statement
Placeholder for a branch you intend to implement later.
x = 10
if x > 5:
pass
else:
print("x is 5 or less")
Try it Yourself โ
pass in a Loop
Useful when you need a loop structure but haven't decided on the body.
items = [1, 2, 3]
for item in items:
pass
Try it Yourself โ
pass in a Function
Define a function without implementing it yet โ useful for stubs.
def future_function():
pass
Try it Yourself โ