--Originally published at Programming
Simple While Loop
Today we are going to talk about while loops. A while loop is a special kind of loop that keeps looping until the given condition equals false. The condition may be an expression. As long as the condition is true, the program will execute the statements within the while loop. When the condition is false, the program passes to the line immediately after the while loop. All statements within the while loop must be indented.
Else Statement with While
In Python, you can use the else-statement with the while loop. It is executed when the condition of the loop becomes False.