December 2000
Intermediate to advanced
816 pages
16h 57m
English
Python's while is the first looping statement we will look at in this chapter. In fact, it is a conditional looping statement. In comparison with an if statement where a true expression will result in a single execution of the if clause suite, the suite in a while clause will be executed continuously in a loop until that condition is no longer satisfied.
Here is the general syntax for a while loop:
while expression: suite_to_repeat
The suite_to_repeat clause of the while loop will be executed continuously in a loop until expression evaluates to Boolean false. This type of looping mechanism is often used in a counting situation, such as the example in the next subsection.
Read now
Unlock full access