Python - Decision control and looping statement - Pass Statement Tutorial
Pass statement is used to bypass the code or to execute nothing (empty/null). Suppose we have a function or loop that is not implement yet. But we want it to implement in future. Therfore, it cannot have empty body, otherwise it will give error. Hence, we use here a pass statement which will execute nothing.
Difference between comment and pass statement is, comment is fully ignored by python interpreter, while pass statement is not ignored by python interpreter.
Syntax-
pass;
Example-
# List of number
number = [4, 1, 2, 27, 25, 73]
# iterate over the list of number
for val in number:
if(val==27):
pass;
print("pass block")
print(val)
Output-
Using Empty function
Syntax-
# Empty Function
def Python_Function(args):
pass
Using Empty Class
Syntax
#Empty Class
class Python_Class:
pass