Wikibooks example doesn't work

John Gordon gordon at panix.com
Wed Aug 6 23:18:35 EDT 2014


In <ilq5u9lfopj0g8227i5ko9s0lhn1ppcacm at 4ax.com> Seymore4Head <Seymore4Head at Hotmail.invalid> writes:

> 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.")
>  
> 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.

It would help tremendously if you gave us more detail than "it doesn't
work".

Do you get an error message?
Does the program not execute at all?
Does it execute, but give unexpected results?

-- 
John Gordon         Imagine what it must be like for a real medical doctor to
gordon at panix.com    watch 'House', or a real serial killer to watch 'Dexter'.





More information about the Python-list mailing list