QuestionQ220

VerifiedData Collections – Tuples, Dictionaries, Lists, and Strings

What is the expected output from the following code?

Question Image

Explanation

Python dictionaries can use tuples as keys. The subscript x[1, 2] denotes the tuple key (1, 2), which maps to the value 1; therefore, the code prints 1.

Community Discussion

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