Python While loop
The Python while loop allows a part of the code to be executed until the given condition returns false. It is also known as a pre-tested loop.
It can be viewed as a repeating if statement. When we don't know the number of iterations then the while loop is most effective to use.
While loop Flowchart

Loop Control Statements
We can change the normal sequence of while loop's execution using the loop control statement. When the while loop's execution is completed, all automatic objects defined in that scope are demolished. Python offers the following control statement to use within the while loop.
1. Continue Statement - When the continue statement is encountered, the control transfer to the beginning of the loop.
2. Break Statement - When the break statement is encountered, it brings control out of the loop.
3. Pass Statement - The pass statement is used to declare the empty loop. It is also used to define empty class, function, and control statement.
0 Comments