while Loops

Python Java
Form:

while <Boolean expression>:
    <statement>
    …
    <statement>

The statements in the loop body are marked by indentation.

The statements in the loop body are marked by indentation.

Form:

while (<Boolean expression>){
    <statement>
    …
    <statement>
}

The statements in the loop body are marked by curly braces ({}). When there is just one statement in the loop body, the braces may be omitted.

The Boolean expression is enclosed in parentheses.

© Ken Lambert. All rights reserved.