04.08.2014 Views

o_18ufhmfmq19t513t3lgmn5l1qa8a.pdf

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

94 CHAPTER 5 ■ CONDITIONALS, LOOPS, AND SOME OTHER STATEMENTS<br />

send mail<br />

wait one month<br />

send mail<br />

wait one month<br />

send mail<br />

wait one month<br />

(...and so on)<br />

But what if you wanted it to continue doing this until you stopped it? Basically, you want<br />

something like this (again, pseudocode):<br />

while we aren't stopped:<br />

send mail<br />

wait one month<br />

Or, let’s take a simpler example. Let’s say that you want to print out all the numbers from<br />

1 to 100. Again, you could do it the stupid way:<br />

print 1<br />

print 2<br />

print 3<br />

. . . and so on. But you didn’t start using Python because you wanted to do stupid things, right?<br />

while Loops<br />

In order to avoid the cumbersome code of the preceding example, it would be useful to be able<br />

to do something like this:<br />

x = 1<br />

while x

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!