<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=Windows-1252">
<meta name="Generator" content="Microsoft Exchange Server">
<!-- converted from text --><style><!-- .EmailQuote { margin-left: 1pt; padding-left: 4pt; border-left: #800000 2px solid; } --></style>
</head>
<body>
<div>The if statement in question isn't inside the while loop.
<div><br>
</div>
<div>White space and indentation is meaningful in python, so putting the if count > 3 block at same indentation as the while statement effectively places it outside the loop. </div>
<div><br>
</div>
<div>Regards,</div>
<div><br>
</div>
<div>Drew</div>
-------- Original message --------<br>
From: Seymore4Head <br>
Date:08/06/2014 20:32 (GMT-08:00) <br>
To: python-list@python.org <br>
Subject: Re: Wikibooks example doesn't work <br>
<br>
</div>
<font size="2"><span style="font-size:10pt;">
<div class="PlainText">On Wed, 06 Aug 2014 22:58:51 -0400, Seymore4Head<br>
<Seymore4Head@Hotmail.invalid> wrote:<br>
<br>
>number = 7<br>
>guess = -1<br>
>count = 0<br>
> <br>
>print("Guess the number!")<br>
>while guess != number:<br>
> guess = int(input("Is it... "))<br>
> count = count + 1<br>
> if guess == number:<br>
> print("Hooray! You guessed it right!")<br>
> elif guess < number:<br>
> print("It's bigger...")<br>
> elif guess > number:<br>
> print("It's not so big.")<br>
<br>
The part to here is supposed to be an example to allow the user to<br>
guess at a number (7) with an infinite amount of tries.<br>
<br>
<br>
This part was added as an exercise.<br>
A counter is added to give 3 tries to guess the number.<br>
It is supposed to stop after count gets to 3. It doesn't. It just<br>
keeps looping back and asking for another guess.<br>
<br>
>if count > 3:<br>
> print("That must have been complicated.")<br>
>else:<br>
> print("Good job!")<br>
><br>
><a href="http://en.wikibooks.org/wiki/Non-Programmer%27s_Tutorial_for_Python_3/Decisions">http://en.wikibooks.org/wiki/Non-Programmer%27s_Tutorial_for_Python_3/Decisions</a><br>
><br>
>Why not?<br>
>I think I know why it isn't working, but I don't know enough yet on<br>
>how it should work.<br>
>The If statement isn't getting read.<br>
-- <br>
<a href="https://mail.python.org/mailman/listinfo/python-list">https://mail.python.org/mailman/listinfo/python-list</a><br>
<br>
</div>
</span></font>
</body>
</html>