What is the output of the following Python code snippet?
d = {'a': 1, 'b': 2}
print(d.pop('a'))
print(d.pop('a'))
Correct answer
C. 1
9 views
C. 1
9 views
pop(key) removes the key and returns its value.
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.