pass
can be used in empty functions & classes definitions and also in empty loops. pass
isn't like continue
, if there is some code after pass
it is executed.## Example 1: Empty function body
def my_fun():
pass
## Example 2: Empty loops
for a in range(10):
pass
# here pass will make sure the for loop doesn't raise a Exception
## Example 3: Another example
for a in range(2):
pass
print("hello") # hello \
# hello
# pass doesn't do anything else, the print statement is executed