December 2000
Intermediate to advanced
816 pages
16h 57m
English
The other looping mechanism in Python comes to us in the form of the for statement. Unlike the traditional conditional looping for statement found in mainstream third-generation languages (3GLs) like C, Fortran, or Pascal, Python's for is more akin to a scripting language's iterative foreach loop.
Iterative loops index through individual elements of a set and terminate when all the items are exhausted. Python's for statement iterates only through sequences, as indicated in the general syntax here:
for iter_var in sequence: suite_to_repeat
The sequence sequence will be iterated over, and with each loop, the iter_var iteration variable is set to the current element of the sequence, presumably for use ...
Read now
Unlock full access