Null number input

Alex Coventry throwaway at mit.edu
Sun Jan 26 16:43:42 EST 2003


using input is usually a bad idea.  you might want to try something
like this:

while 1:
    age = raw_input('Age: ')
    try:
        userInfo['age'] = int(age)
    except ValueError:
        # whatever error handling you want to do, here.
        pass
    else:
        break

alex.




More information about the Python-list mailing list