What is the output of print({1: 'a', True: 'b'}) in Python?
print({1: 'a', True: 'b'})
Correct answer
B. {1: 'b'}
5 views
B. {1: 'b'}
5 views
1 and True hash equal, so they are the same dictionary key; the first key is kept and the value overwritten.
Asked in: Python Interview Output Prediction
https://docs.python.org/3/reference/datamodel.htmlNot sure why the answer is B? Ask here and get an explanation.