QuestionQ79

VerifiedExceptions

What is the expected behavior for the following code?

Question Image

Explanation

Converting '2A' with int() raises ValueError because it is not a valid integer literal. The matching except ValueError block assigns 2 to n, so print(n) outputs 2.

Learn more

Community Discussion

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