In this example we will show how to run a block of code once when the condition of the while loop is not true in Python.
Source Code
a = 3
while a < 20:
print("'a' is less than 20, it is: ", a)
a += 4
else:
print("'a' is no longer less than 20")
Output:
'a' is less than 20, it is: 3
'a' is less than 20, it is: 7
'a' is less than 20, it is: 11
'a' is less than 20, it is: 15
'a' is less than 20, it is: 19
'a' is no longer less than 20