raise systemexit(def menu(self)tryanswer "while trueprint(""please enter command\tlogin\tlogin \ttest\ttest the program \tchange\tchange the program \tquit\tquit """answer input("enter command"lower(tryfunc self menu_map[answerexcept keyerrorprint("{is not valid optionformatanswer)elsefunc(finallyprint("thank you for testing the auth module"editor(menu(this rather long example is conceptually very simple the is_permitted method is probably the most interestingthis is mostly internal method that is called by both test and change to ensure the user is permitted access before continuing of coursethose two methods are stubsbut we aren' writing an editor herewe're illustrating the use of exceptions and exception handlers by testing an authentication and authorization frameworkexercises if you've never dealt with exceptions beforethe first thing you need to do is look at any old python code you've written and notice if there are places you should have been handling exceptions how would you handle themdo you need to handle them at allsometimesletting the exception propagate to the console is the best way to communicate to the userespecially if the user is also the script' coder sometimesyou can recover from the error and allow the program to continue sometimesyou can only reformat the error into something the user can understand and display it to them