Introduction
The very basics of text files
with statement and exception handling
9. Exceptions
Summary

## Instruction

All right! Now that you know two ways of working with text files, let's move on and perform a tiny experiment: what happens when you try to open a file that doesn't exist?

## Exercise

Take a look at the template code. Provide a non-existent file name – magic_file.txt – as the argument of open(), and run the code.

As you can see, Python shows an error. It doesn't look very nice, and we don't really want our users to see something like this if we're writing an application. That's why we need to learn how to handle such situations properly.

Click to continue.