Chapter 6. Going Loopy

Nothing is worse than having to do the same thing over and over again. There’s a reason why some people count sheep when they’re having trouble falling asleep, and it has nothing to do with the amazing sleep-inducing powers of woolly mammals. It’s because endlessly repeating something is boring, and your mind can drop off to sleep more easily if you’re not focusing on something interesting.

Programmers don’t particularly like repeating themselves either, unless they’re also trying to fall asleep. Thankfully, most programming languages have what is called a for loop, which repeats things like other programming statements and blocks of code automatically.

In this chapter, we’ll look at for loops, as well as another type of loop ...

Get Python for Kids now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.