Pass Statement

Pass Statement

The pass statement is a null operation; nothing happens when it executes. The pass is also useful in places where your code will eventually go, but has not been written yet (e.g., in stubs for example):

Syntax:

pass

Example :

for i in [1,2,3,4,5]:
    if i==3:
        pass
        print('Pass when value is',i)
    print (i)

Output:

>>>  
1
2
Pass when value is 3
3
4
5
>>>

Example 2 :

for letter in 'Python':
   if letter == 'h':
      pass
      print('This is pass block')
   print('Current Letter :', letter)

print("Good bye!")

Output :

Current Letter : P
Current Letter : y
Current Letter : t
This is pass block
Current Letter : h
Current Letter : o
Current Letter : n
Good bye!