Use else with while loop in Python
Author: Al-mamun Sarkar
Date: 2020-03-25 08:35:54
Use else with the while loop in Python programming language.
n = 1
while n <= 10:
print(n)
n = n + 1
else:
print('The loop is over.')
Output:
1
2
3
4
5
6
7
8
9
10
The loop is over.