Free Trial

Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.

  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint
Share this Page URL
Help

I. Learning to Program > 6. Going Loopy

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.

image with no caption

In this chapter, we’ll look at for loops, as well as another type of loop that Python offers: the while loop.


  

You are currently reading a PREVIEW of this book.

                                                                                                                    

Get instant access to over $1 million worth of books and videos.

  

Start a Free Trial


  
  • Safari Books Online
  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint