How to use else statement with Loops in Python?

PythonServer Side ProgrammingProgramming

The else block is executed after iterations and before program control exits loop block

x=0
while x<5:
   x=x+1
   print (x)
else:
   print ("else block of loop")
print ("loop is over")
raja
Published on 17-Feb-2018 13:20:41
Advertisements