the code in try block workspython skips over the except block if the code in the try block causes an errorpython looks for an except block whose error matches the one that was raised and runs the code in that block in this examplethe code in the try block produces zerodivisionerrorso python looks for an except block telling it how to respond python then runs the code in that blockand the user sees friendly error message instead of tracebackyou can' divide by zeroif more code followed the tryexcept blockthe program would continue running because we told python how to handle the error let' look at an example where catching an error can allow program to continue running using exceptions to prevent crashes handling errors correctly is especially important when the program has more work to do after the error occurs this happens often in programs that prompt users for input if the program responds to invalid input appropriatelyit can prompt for more valid input instead of crashing let' create simple calculator that does only divisiondivision py print("give me two numbersand 'll divide them "print("enter 'qto quit "while truefirst_number input("\nfirst number"if first_number =' 'break second_number input("second number"if second_number =' 'break answer int(first_numberint(second_numberprint(answeru this program prompts the user to input first_number andif the user does not enter to quita second_number we then divide these two numbers to get an answer this program does nothing to handle errorsso asking it to divide by zero causes it to crashgive me two numbersand 'll divide them enter 'qto quit first number second number traceback (most recent call last)file "division py"line in answer int(first_numberint(second_numberzerodivisionerrordivision by zero files and exceptions