Page 103 - TP-Play_V-2.0_Book-8
P. 103

Program 4: To demonstrate the use of a while loop


















            You will get the following output:




























             Clickipedia


              Any non-zero value in the while loop indicates always a true condition, whereas zero indicates
              always a false condition.


            The while Loop using else Statement

            Python enables the use of else statement with the while loop. The else block is executed when
            the condition given in the while statement becomes false.

            Program 5: To demonstrate the use of while loop with else statement

















                                                                                       Loops in Python      103
   98   99   100   101   102   103   104   105   106   107   108