choose runrun module you see python shell window open the application displays the letter sequencealong with the letter numberas shown in figure - figure - custom exceptions can make your code easier to read using the finally clause normally you want to handle any exception that occurs in way that doesn' cause the application to crash howeversometimes you can' do anything to fix the problemand the application is most definitely going to crash at this pointyour goal is to cause the application to crash gracefullywhich means closing files so that the user doesn' lose data and performing other tasks of that nature anything you can do to keep damage to data and the system to minimum is an essential part of handling data for crashing application the finally clause is part of the crashing-application strategy you use this clause to perform any required last-minute tasks normallythe finally clause is quite short and uses only calls that are likely to succeed without further problem it' essential to close the fileslog the user offand perform other required tasksand then let the application crash before something terrible happens (such as total system failurewith this necessity in mindthe following steps show simple example of using the finally clause this example also appears with the downloadable source code as exceptionwithfinally py open python file window you see an editor in which you can type the example code