/* */ Click to Join Live Class with Shankar sir Call 9798158723

The pass statement in python


the pass statement does not do anything. it is used with if statement or inside a loop to represent no operation. we pass statement when need a statement syntactically but we do not want to do any operation. the continue statement redirected to flow execution to the beginning of the loop if we use pass in the place of continue the numbers from 1 to 10 are displayed as if there is no effect of pass.

Syntax:-


while condition:

    if  condition:
       pass;
  statement


Note:-four space are python indentation


Q.) Program to demonstrate the pass statement.
 
 i=1;
 while i<=5:
   print(i);
   if i==2
      pass		      
   i=i+1   
 
 
Output
 1 2 3 4 5 

Program Explanation

a more meaningful usage of pass statement is to inform the python interpreter not to do anything when we are not interested in the result.


«  PREVIOUS PAGE NEXT PAGE »