type the following code into the window -pressing enter after each lineimport sys tryraise valueerror print("raising an exception "except valueerrorprint("valueerror exception!"sys exit(finallyprint("taking care of last minute details "print("this code will never execute "in this examplethe code raises valueerror exception the except clause executes as normal when this happens the call to sys exit(means that the application exits after the exception is handled perhaps the application can' recover in this particular instancebut the application normally endswhich is why the final print(function call won' ever execute the finally clause code always executes it doesn' matter whether the exception happens or not the code you place in this block needs to be common code that you always want to execute for examplewhen working with fileyou place the code to close the file into this block to ensure that the data isn' damaged by remaining in memory rather than going to disk choose runrun module you see python shell window open the application displays the except clause message and the finally clause messageas shown in figure - the sys exit(call prevents any other code from executing figure - use the finally clause to ensure spe cific actions take place before the application ends