QuestionQ10

VerifiedExceptions

What is the expected behavior of the following code?

Question Image

Explanation

Looking up the missing dictionary key '3' raises KeyError. Because KeyError is a built-in exception under BaseException, the handler catches it and print(type(error)) outputs <class 'KeyError'>.

Learn more

Community Discussion

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