Hour 7. Using Loops to Repeat Code

What You’ll Learn in This Hour:

Image How to repeat a block of code a set number of times

Image How to repeat code as long as something is true

Image When to use loops in the real world

A loop is a bit of code that is repeated. Sometimes it’s repeated a set number of times. Sometimes it’s repeated until a certain condition is true. Other times, it repeats until the user tells it to stop.

Most programs are written inside of loops. ...

Get Python in 24 Hours, Sams Teach Yourself, Second Edition 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.