Python while Loop Statements
While loop is used in Python to repeat a block of code until the condition in while statement is true. It is also used quite frequently in Python.
The syntax of while in python is given below.
while loop with else
We can use an optional block with a while loop that will execute once the loop is terminated. But one thing to notice is that, if the loop contains any loop control statement ( i.e. break, continue or pass ), then the else block is not executed.
i = 1
i = i + 1