Python pass Statement

❮ Python Keywords


Example

Create a placeholder for future code:

for x in [0, 1, 2]:
  pass
Try it Yourself »

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
Try it Yourself »

Example

Using the pass keyword in a class definition:

class Person:
  pass
Try it Yourself »

Example

Using the pass keyword in an if statement:

a = 33
b = 200

if b > a:
  pass
Try it Yourself »

❮ Python Keywords

Copyright 1999-2023 by Refsnes Data. All Rights Reserved.