Python pass Statement
❮ Python Keywords
Example
Create a placeholder for future code:
for x in [0, 1, 2]:
pass
Run example »
Definition and Usage
The pass
statement is used as a placeholder
for future code.
When the pass
statement is executed, nothing
happens, but you avoid getting an error when empty code is not allowed.
Empty code is not allowed in loops, function definitions, class definitions,
or in if statements.
More Examples
Example
Using the pass
keyword in a
function
definition:
def myfunction:
pass
Run example »
Example
Using the pass
keyword in a
class
definition:
class Person:
pass
Run example »
Example
Using the pass
keyword in an
if
statement:
a = 33
b = 200
if b > a:
pass
Run example »
❮ Python Keywords