Pass Statement in Python

Updated: Jun 23



The pass statement acts as a placeholder and frequently used when there is no need of code but a statement is still essential to make a code syntactically correct. A python comment works similar to the pass statement as it does nothing so we can use comment in place of pass statement. A comment is completely ignored by the Python interpreter whereas pass is not ignored by interpreter, it says the interpreter to do nothing.



Example:

for n in [10, 11, 9, 76, 4, 7, 52]:

if n%2 == 0:

pass

else:

print(n)


Output:

11

9

7



Recent Posts

See All

Python Modules

A module is a file containing Python definitions and statements. A module can characterize functions, classes and variables. A module can likewise incorporate runnable code. Gathering related code int

Command Line Arguments in Python

Command Line Arguments are the arguments that are specified after the name of the program in the command line shell of the operating system. Python gives different ways of dealing with these types of