count = 5 while count > 0: count = count - 1 print(count)
The code inside the
while block runs as long as the condition
count > 0 evaluates to True.
This will print 4 3 2 1 0 on Console.
count = 5 while count > 0: count = count - 1 print(count) else: print('done')
else block in While loop runs when the condition evaluates to False.
else block won't be run if:
- the exception happens inside the block
This will print 4 3 2 1 0 done on Console.