> i'm trying to write a code that handle errors help > > def print_menu(): ...
Personally I try to get the menu function to return the value selected that way the meniu options and the code to check it is all wrapped up in the same place. But that is only a side issue... > while menu_choice != 5: > menu_choice = input("Type in a number (1-5):") > break > except(TypeError,NameError): You need to use try: before an except. So if you start your while loop body with a try while menu_choice != 5: try: menu_choice = input(...) if menu_choice == 1: etc... except NameError, TypeError: # handle error here break # only if you really need to.. print_menu() HTH, Alan G Author of the Learn to Program web tutor http://www.freenetpages.co.uk/hp/alan.gauld _______________________________________________ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor