Chapter 8. Loop the Loop
For most people, doing the same thing over and over again is very boring, so why not let the computer do that for us? Computers never get bored, so they’re great at doing repetitive tasks. In this chapter, we’re going to see how to make the computer repeat things.
Computer programs often repeat the same steps over and over again. This is called looping. There are two main kinds of loops:
- those that repeat a certain number of times—these are called counting loops
- those that repeat until a certain thing happens—these are called conditional loops because they keep going until some condition is true
Counting loops
Get Hello World! 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.