While Loop With else Statement Use in Python

The relation of while Loop else is made. As long as the condition is true, while the statement of the while loop iterates and the condition is false then the control pass is passed and executing the else statement.

While Loop With else in Python, Use While Loop With else Condition use in Python, How Can i Use While Loop With else Statement in Python

Source Code :

a = 0
while(a < 10):
print("Value of a is ", a);
a = a + 1
else:
print("Out of Loop");

Output :

Value of a is 0
Value of a is 1
Value of a is 2
Value of a is 3
Value of a is 4
Value of a is 5
Value of a is 6
Value of a is 7
Value of a is 8
Value of a is 9