0

In this code i am checking for an error when trying to open the file but how can i also check for an error when reading the file?

try:
    with open("file.txt") as f:
        contents = f.read()
except FileNotFoundError:
    print("File Not Found")

1 Answers1

0

You can have multiple except statements. So just add another one after your current except for the error that you want to deal with this time.

Ethan
  • 82
  • 1
  • 6