What is the output of the following Python code snippet?
d = {'a': 1}
print(d.get('z', 0))
print(d.get('z', 0))
Correct answer
D. 0
D. 0
get(key, default) returns the default when the key is absent.
Asked in: Python Interview Dictionaries
https://docs.python.org/3/tutorial/datastructures.html#dictionariesNot sure why the answer is D? Ask here and get an explanation.