QuestionQ118

VerifiedExceptions

What output is expected from the following code when no file named non_existing_file exists in the working directory?

Question Image

Explanation

Opening a missing file for reading raises an IOError/OSError with errno 2 (ENOENT, meaning no such file or directory). The exception handler prints that errno and then prints 2; the else block runs only when no exception occurs.

Learn more

Community Discussion

No comments yet. Be the first to start the discussion!