QuestionQ86

VerifiedExceptions

What behavior is expected from the following code?

Question Image

Explanation

Tuples are immutable, so assigning to my_tuple[3] raises a TypeError stating that a tuple object does not support item assignment. That exception is caught by except Exception as exception, and print(x) outputs the error message.

Community Discussion

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