Learnerslesson
   JAVA   
  SPRING  
  SPRINGBOOT  
 HIBERNATE 
  HADOOP  
   HIVE   
   ALGORITHMS   
   PYTHON   
   GO   
   KOTLIN   
   C#   
   RUBY   
   C++   




PYTHON - PASS


What happens if you have not written anything inside 'for' or 'while loop' or 'if block'?


Example :


for x in "Hello World":


Output :



  SyntaxError : unexpected EOF while parsing

Well! It ended up with an Error.


But why do we not specify anything inside the 'for loop'? Isn't the 'for loop' meant to perform some task?


Well! Maybe we want to write the code later. For the current moment we want to keep it empty.


And in such cases. The 'pass' statement comes to rescue.


So, let us rewrite the above example of empty 'for loop' using 'pass' statement.


'pass' statement in 'for loop'


Example :


for x in "Hello World":
    pass


Output :



So, with the 'pass' statement, you can correct the above 'for loop'.


'pass' statement in 'while loop'


Example :


x = 5
while x < 5:
    pass


Output :



And the above statement haven't ended up with an error.


'pass' statement in 'while loop'


Example :


x = 2
if x < 4:
    pass


Output :



Similarly, the above statement haven't ended up with an error.