What's wrong with this code?
John Machin
sjmachin at lexicon.net
Sat Jul 2 20:20:19 EDT 2005
John Machin wrote:
> Nathan Pinno wrote:
>> guess = input("Guess a number: ")
>
>
> "guess" will refer to a string e.g. "42" which will *not* compare equal
> to the integer 42. Also you should use raw_input, not input.
>
> so do this:
>
> guess = int(raw_input("Guess a number: "))
>
Ahem ... I'll redo that:
You'd be better using raw_input, which *then* means you need to wrap
int() around it, ending up with the same recommendation:
guess = int(raw_input("Guess a number: "))
Cheers,
John
More information about the Python-list
mailing list