What will be the output of the following Python code? [code] a={1:5,2:3,3:4} print(a.pop(4,9)) [/code]

What will be the output of the following Python code?
Code:
a={1:5,2:3,3:4}
print(a.pop(4,9))
A. 9
B. 3
C. Too many arguments for pop() method
D. 4
 
Answer: a
Explanation: pop() method returns the value when the key is passed as an argument and otherwise returns the default value(second argument) if the key isn’t present in the dictionary.
 

Tìm kiếm

Back
Top