when I try this
if question.isdigit() is True:
I can type in numbers fine, and this would filter out alpha/alphanumeric strings
whe
If you do not wish to go for try... except, you could use regular expression
if re.match("[+-]?\d", question) is not None:
question = int(question)
else:
print "Not a valid number"
With try... except, it is simpler:
try:
question = int(question)
except ValueError:
print "Not a valid number"
If isdigit is must and you need to preserve the original value as well, you can either use lstrip as mentioned in an answer given. Another solution will be:
if question[0]=="-":
if question[1:].isdigit():
print "Number"
else:
if question.isdigit():
print "Number"