June 2024
Beginner to intermediate
908 pages
15h 59m
English
In Chapter 24, as you certainly noticed, the while statement was used to iterate for both a known number and an unknown number of times (in situations where the number of iterations was not known at the time the loop started iterating). In other words, the while statement was used to create both definite and indefinite loops.
Since definite loops are so frequently used in computer programming, almost every computer language, including Python, incorporates a special statement that is notably more readable and convenient than the while statement—and this is the for statement.
The general form of the for statement, is
where element is a ...
Read now
Unlock full access