DekGenius.com
[ Team LiB ] Previous Section Next Section

Chapter 10. while and for Loops

In this chapter, we meet Python's two main looping constructs—statements that repeat an action over and over. The first of these, the while loop, provides a way to code general loops; the second, the for statement, is designed for stepping through the items in a sequence object and running a block of code for each item.

There are other kinds of looping operations in Python, but the two statements covered here are the primary syntax provided for coding repeated actions. We'll also study a few unusual statements such as break and continue here, because they are used within loops.

    [ Team LiB ] Previous Section Next Section