| Python Language Reference Manual by Guido van Rossum and Fred L. Drake, Jr. Paperback (6"x9"), 120 pages ISBN 0954161785 RRP £12.95 ($19.95) Sales of this book support the Python Software Foundation! Get a printed copy>>> |
7.2 The while statement
The while statement is used for repeated execution as long
as an expression is true:
while_stmt "while"expression":"suite-
["else" ":"
suite]
This repeatedly tests the expression and, if it is true, executes the
first suite; if the expression is false (which may be the first time it
is tested) the suite of the else clause, if present, is
executed and the loop terminates.
A break statement executed in the first suite terminates the
loop without executing the suite of the else clause. A
continue statement executed in the first suite skips the rest
of the suite and goes back to testing the expression.
| ISBN 0954161785 | Python Language Reference Manual | See the print edition |