for Statements

>>> # Measure some strings:
... words = ['cat', 'window', 'defenestrate']
>>> for w in words:
...     print(w, len(w))
cat 3
window 6
defenestrate 12

Differs a bit from what you may be used to in C or Pascal.

Rather than always iterating over an arithmetic progression of numbers (like in Pascal), or giving the user the ability to define both the iteration step and halting condition (as C), it iterates over the items of any sequence (a list or a string), in the order that they appear in the sequence.

Related concepts

for Statements — Structure map

Clickable & Draggable!

for Statements — Related pages: