Oct-21-2017, 07:06 AM
because once counter is incremented to 5 in some of the previous iterations, it will not enter the loop at all. that is also the reason while you don't need to check counter<5 in lines 9 and 12.
counter = 0 while counter<5: print(counter) counter += 1
Output:0
1
2
3
4
eventually you can change it to while<=5
counter = 0 while counter<=5: print(counter) counter += 1
Output:0
1
2
3
4
5