[Tutor] How to check if user input is an integer

Mark Lawrence breamoreboy at yahoo.co.uk
Fri Mar 29 14:13:37 CET 2013


On 29/03/2013 12:21, Shall, Sydney wrote:
> or;
> where x is the input == fiftypencecoins;
>
> return isinstance(x, int)
>
> will return True or False
>
> Then you can proceed as you wish.

If you enter invalid input you'll never get x to be an int so how can 
you test it with isinstance?

-- 
If you're using GoogleCrap™ please read this 
http://wiki.python.org/moin/GoogleGroupsPython.

Mark Lawrence



More information about the Tutor mailing list