Pass Statement in Python

Updated: Feb 25, 2021



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



13 views0 comments

Recent Posts

See All

Tell () function can be used to get the position of file handle and returns current position of file object where as Seek () function is used to change the position of the file handle to a given speci

Seek () function is used to change the position of the file handle to a given specific position in python. File handle such as a cursor which defines from where the data has to be read or written in t

Slicing is a Python attitude that enables accessing parts of data from the given sequence like list, tuples etc. A slice object is created based on a set of indices. Slicing starts anywhere from list