[Tutor] Convert String to Int

Alan Gauld alan.gauld at btinternet.com
Mon Jan 19 10:14:39 CET 2009


"bob gailer" <bgailer at gmail.com> wrote 

> a = raw_input("Enter an integer:")
> if a.isdigit():
>  # process input

Oops, yes. My posting on this is wrong because you can't 
compare to int untl after you convert the value. isdigit() 
is the correct check.

Apologies - too early in the morning...

Alan G



More information about the Tutor mailing list