Suppose we have a loop or a function that is not implemented yet, but we want to implement it in the future. They cannot have an empty body. The interpreter would complain. So, we use the pass
statement to construct a body that does nothing.
>>> for i in [1,2,3,4,5,6,7,8,9]:
if i==3:
pass
print ("Pass when value is : ",i)
print (i,)
Pass when value is : 1
1
Pass when value is : 2
2
Pass when value is : 3
3
Pass when value is : 4
4
Pass when value is : 5
5
Pass when value is : 6
6
Pass when value is : 7
7
Pass when value is : 8
8
Pass when value is : 9
9
>>>
Our website is made possible by displaying ads to our visitors.
Please help us continue to provide you with free. So please disabling your ad blocker.