/    /  Python – Pass

Python – Pass:

Pass statement is used when there is a situation where a statement is required for syntax in the code, but which should not to be executed. So that, When the program executes that portion of code will not be executed.

In the below example, we can observe that the pass statement in if condition was not executed.

Example:

>>> for i in range(100,104):

...     print('Assigned value of i is ',i)

...     for num in range(100,i):

...                             print(i,num)

...     if num==102:

...             pass

...    

...

Below is the Output:

Assigned value of iis  100

Assigned value of iis  101

101 100

Assigned value of iis  102

102 100

102 101

Assigned value of iis  103

103 100

103 101

103 102

In the below example, we can observe that the pass statement is not mentioned. Hence resulted an error.

Example:

>>> for i in range(100,104):

...     print('Assigned value of i is ',i)

...     for num in range(100,i):

...                             print(i,num)

...     if num==102:

...

  File "<stdin>", line 6



    ^

IndentationError: expected an indented block