Ian Egland wrote:
'Allo All.
I know that, should you want to get an int from the user, you use
int(input("Question!")). However, what if the user wasn't that savvy
and didn't realize he/she HAD to enter a number? Program crash. Is
there a way that I can get the input as a string, check and see if
it's convertible to an integer, convert it if it is and ask them to
try again if it's not?
a = raw_input("Enter an integer:")
if a.isdigit():
# process input
else:
# complain
--
Bob Gailer
Chapel Hill NC
919-636-4239
_______________________________________________
Tutor maillist - Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor