finallyprint('finally run'print('after run'print(sep 'exception raised but not caught'tryx except indexerrorprint('except run'finallyprint('finally run'print('after run'when this code is runthe following output is produced in python in xits behavior and output are the same because the print calls each print single itemthough the error message text varies slightly trace through the code to see how exception handling produces the output of each of the four tests herec:\codepy - mergedexc py exception raised and caught except run finally run after run no exception raised finally run after run no exception raisedwith else else run finally run after run exception raised but not caught finally run traceback (most recent call last)file "mergedexc py"line in zerodivisionerrordivision by zero this example uses built-in operations in the main action to trigger exceptions (or not)and it relies on the fact that python always checks for errors as code is running the next section shows how to raise exceptions manually instead the raise statement to trigger exceptions explicitlyyou can code raise statements their general form is simple-- raise statement consists of the word raiseoptionally followed by the class to be raised or an instance of it exception coding details