Computer Science

Explain the use of the pass statement. Illustrate it with an example.

Python Funda

36 Likes

Answer

The pass statement of Python is a do nothing statement i.e. empty statement or null operation statement. It is useful in scenarios where syntax of the language requires the presence of a statement but the logic of the program does not. For example,

for i in range(10):
    if i == 2:
        pass
    else:
        print("i =", i)

Answered By

25 Likes


Related Questions