QuestionQ77

VerifiedData Collections – Tuples, Dictionaries, Lists, and Strings

Insert the correct snippet to convert the tuple t into a dictionary named d.

Expected output:

Question Image

Code:

Question Image

Explanation

Python’s dict() constructor accepts an iterable of two-item key-value pairs. Passing t to dict(t) creates the dictionary {'A': 1, 'B': 2, 'C': 3} and assigns it to d.

Community Discussion

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