What is the output of print(list({'a': 1, 'b': 2}.items())) in Python?
print(list({'a': 1, 'b': 2}.items()))
Correct answer
B. [('a', 1), ('b', 2)]
6 views
B. [('a', 1), ('b', 2)]
6 views
items() returns key-value pairs as tuples.
Asked in: Python Interview Dictionaries
https://docs.python.org/3/tutorial/datastructures.html#dictionariesNot sure why the answer is B? Ask here and get an explanation.