search
[last updated: 2024-09-21]
Python home page
Python: Programming
-----
On this page:
-----
the 'range' can be a predefined list, eg:
listToRun = {1, 4, 6, 7}
for x in listToRun:
[statements]
If you want to break out of the for-loop before it's done:
if [expression]:
if [expression]:
break
The [expression] can be any statement that evaluates to T/F
The else statement is optional but there can only be one of them at most.
If you have more than one 'else' condition to test, use elif:
if [expression]:
[statements]
elif [expression]:
[statements]
elif [expression]:
[statements]
.
.
.
eof