statements operators functions string methods set methods tuple methods dict methods file methods list methods exceptions exception types comprehensions multidimensionals os lambdas subprocess
Intro to Python

Session 1 Session 2 Session 3 Session 4 Session 5 Session 6 Session 7 Session 8 Session 9




pythonreference.com

search statements, functions, methods, exceptions*

hide categories

'while' statement
execute block repeatedly until test is False (or 'break' is encountered)
var = 0
while var < 3:
    var = var + 1
    print(var)
initialize int while int is less than 3: increment int print int
1) if the test in this statement is True, enter the block (while True is True) 2) when the end of the block is reached, return to the top of the block and evaluate the test in this statement again (see above -- while True is always True) 3) if a break statement is reached, drop to the first line after the block 4) if a continue statement is reached, return to the top of the block and evaluate the test in this statement again (see above -- while True is always True)