try: except: ValueError

Mike Hoy mhoy4 at cox.net
Fri Jun 10 15:23:15 EDT 2005


> The solution is to use raw_input() which returns the user input as a string. Then you can do whatever validation you wish, e.g.
>   menuChoice = int(raw_input("1 = write | 2 = view | 0 = quit"))
> which will raise an exception if the input is not a valid integer.
yes that did it, thanks




More information about the Python-list mailing list