Wikibooks example doesn't work
Seymore4Head
Seymore4Head at Hotmail.invalid
Wed Aug 6 23:25:27 EDT 2014
On Wed, 06 Aug 2014 22:58:51 -0400, Seymore4Head
<Seymore4Head at Hotmail.invalid> wrote:
>number = 7
>guess = -1
>count = 0
>
>print("Guess the number!")
>while guess != number:
> guess = int(input("Is it... "))
> count = count + 1
> if guess == number:
> print("Hooray! You guessed it right!")
> elif guess < number:
> print("It's bigger...")
> elif guess > number:
> print("It's not so big.")
The part to here is supposed to be an example to allow the user to
guess at a number (7) with an infinite amount of tries.
This part was added as an exercise.
A counter is added to give 3 tries to guess the number.
It is supposed to stop after count gets to 3. It doesn't. It just
keeps looping back and asking for another guess.
>if count > 3:
> print("That must have been complicated.")
>else:
> print("Good job!")
>
>http://en.wikibooks.org/wiki/Non-Programmer%27s_Tutorial_for_Python_3/Decisions
>
>Why not?
>I think I know why it isn't working, but I don't know enough yet on
>how it should work.
>The If statement isn't getting read.
More information about the Python-list
mailing list