What is the output of print({'a': 1, 'b': 2}.keys() - {'a': 0}.keys()) in Python?
print({'a': 1, 'b': 2}.keys() - {'a': 0}.keys())
Correct answer
A. {'b'}
6 views
A. {'b'}
6 views
Subtracting key views gives the keys unique to the first dictionary.
Asked in: Python Interview Dictionaries
https://docs.python.org/3/tutorial/datastructures.html#dictionariesNot sure why the answer is A? Ask here and get an explanation.