msg "sorrythe file filename does not exist print(msgin this examplethe code in the try block produces filenotfounderrorso python looks for an except block that matches that error python then runs the code in that blockand the result is friendly error message instead of tracebacksorrythe file alice txt does not exist the program has nothing more to do if the file doesn' existso the error-handling code doesn' add much to this program let' build on this example and see how exception handling can help when you're working with more than one file analyzing text you can analyze text files containing entire books many classic works of literature are available as simple text files because they are in the public domain the texts used in this section come from project gutenberg (if you're interested in working with literary texts in your programming projects let' pull in the text of alice in wonderland and try to count the number of words in the text we'll use the string method split()which can build list of words from string here' what split(does with string containing just the title "alice in wonderland"title "alice in wonderlandtitle split(['alice''in''wonderland'the split(method separates string into parts wherever it finds space and stores all the parts of the string in list the result is list of words from the stringalthough some punctuation may also appear with some of the words to count the number of words in alice in wonderlandwe'll use split(on the entire text then we'll count the items in the list to get rough idea of the number of words in the textfilename 'alice txttrywith open(filenameas f_objcontents f_obj read(except filenotfounderrormsg "sorrythe file filename does not exist print(msg