while
The while
loop in Python works much as it does in many other programming languages, by looping an indefinite number of times and testing a condition before each iteration. If the condition is False
, the loop ends.
>>> i = 0
>>> while i < 10:
... i = i + 1
...
>>> print i
10
There is no loop...until
construct in Python.