It is a Null Statement. A statement which will do nothing. It is generally used as a placeholder.
Sometimes, pass
is used when the user doesn’t want any code to execute. So user simply places pass
there as empty code is not allowed in loops, function definitions, class definitions, or in if statements.
def func(args):
pass
class Python:
pass
print(" Executed")
Output: Executed
It is generally used to avoid error.
if 1 + 1 == 2:
Output: SyntaxError:invalid syntax
if 1 + 1 == 2:
pass
No error, nothing will display.
- Log in to post comments