What is the output of print({'a': 1, 'b': 2} | {'b': 3}) in Python?
print({'a': 1, 'b': 2} | {'b': 3})
Correct answer
C. {'a': 1, 'b': 3}
5 views
C. {'a': 1, 'b': 3}
5 views
The | operator (Python 3.9+) merges dicts; the right operand wins on conflicts.
Asked in: Python Interview Dictionaries
https://docs.python.org/3/tutorial/datastructures.html#dictionariesNot sure why the answer is C? Ask here and get an explanation.