The Python pass statement is used as a placeholder for future code. Pass in Python is the same as a comment. It does nothing in Python code. The difference between pass and comment is, the Python interpreter ignores comments written in the code, but the pass statement is not ignored. The empty code blocks are not allowed in Python so that the pass statement is used as a null statement in Python. Let’s see an example of a pass statement.
Python Pass Statement Example
a = int(input("Enter first number")) b = int(input("Enter second number")) if(a==0 and b==0): pass else: print(a/b)
Enter first number10 Enter second number2 5.0
If one of the inputs is zero in the above code, then the division is not possible. So that we used the pass statement, if both numbers are non zero then only the division is possible.
A pass statement is a null statement that does nothing in the code. This statement is used to create an empty function, class, or block of code.