What will be the output of {'a': 1, 'b': 2}.values() in Python?
Correct answer
A. [1, 2]
11 views
A. [1, 2]
11 views
values() returns a dict_values view object, shown as dict_values([1, 2]). Of the options given, [1, 2] is the closest, since the view contains the values 1 and 2 in a list-like form; it is not a tuple or dictionary.
Not sure why the answer is A? Ask here and get an explanation.