What is the output of print(len({1: 'a', 2: 'b', 1.0: 'c', 3: 'd'})) in Python?
print(len({1: 'a', 2: 'b', 1.0: 'c', 3: 'd'}))
Correct answer
A. 3
5 views
A. 3
5 views
Dict comprehension keys 1 and 1.0 collide because they are equal.
Asked in: Python Interview Output Prediction
https://docs.python.org/3/reference/datamodel.htmlNot sure why the answer is A? Ask here and get an explanation.