14.4. The while construct: looping
To execute a section of the program repeatedly:
while E:
Bt
else:
Bf
The else: part is optional.
Here's how the statement is executed:
Evaluate the expression
E.
If that expression is false, go to
Step 3. Otherwise go to
Step 2.
Execute block
Bt, and then return to Step 1.
If there is an else:
block
Bf,
execute it, otherwise do nothing.