Python School

While Loops

There are two types of loop in Python

While loops are known as indefinite or conditional loops. They will keep iterating until certain conditions are met. There is no guarantee ahead of time regarding how many times the loop will iterate.

The while loop, like the if statement, includes a boolean expression that evaluates to true or false. The code inside the loop will be repeatedly executed until the boolean expression is no longer true. This diagram shows the flow of control in a while loop. While example

This video clip gives you some examples of writing while loops in Python.

While loops in Python