Chapter 8. Conditionals and Loops

Chapter Topics

  • if statement

  • else statement

  • elif statement

  • while statement

  • for statement

    • range() built-in function

  • break statement

  • continue statement

  • pass statement

  • else statement… take two

The primary focus of this chapter are Python's conditional and looping statements, and all their related components. We will take a close look at if, while, for, and their friends else, elif, break, continue, and pass.

Get Core Python Programming now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.