In Python, pass
is a null
statement. The interpreter does not ignore a pass
statement, but nothing happens and the statement results into no operation.
The pass
statement is useful when you don’t write the implementation of a function but you want to implement it in the future.
So, to avoid compilation errors, you can use the
pass
statement.
The syntax of the pass
statement is:
pass
addition()
function has no implemention:
def addition(num1, num2):# Implementation will go herepass # Pass statementaddition(2, 2)
if
statement implementationif
statement has no implementation:
# This functions prints the number if its not 2def display(number):if number is 2:pass # Pass statementelse:print ("Number: ", number)display(2)display(3)