[Tutor] Input checking [letters or numbers]

Panagiotis Atmatzidis p.atmatzidis at gmail.com
Fri Dec 23 19:15:46 CET 2005


Hello,

Can someone provide me with an error checking example about an x
variable that needs to be number only? I used something like:

 def useridf():
     print ""
     print "WARNING: If you don't understand why this must be unique,
exit and read the manual."
     print ""
     userid = input("x : ")

I know that "input" accepts only numbers, but I don't want the program
to break if someone puts other chars in it. I want to, print "Only
numbers are accepted." which is easy. But still I can't understand how
to do the check using if/elif/else statements.


More information about the Tutor mailing list