Python Programming - Dictionaries - Discussion

Discussion Forum : Dictionaries - General Questions (Q.No. 36)
36.
What does the dictionary.pop(key, None) method do?
Removes the specified key from the dictionary.
Raises a KeyError if the key is not present.
Removes a random key-value pair from the dictionary.
Removes the specified key and returns its value, or returns None if the key is not present.
Answer: Option
Explanation:
The pop() method with a default value of None removes a key-value pair from a dictionary without raising an error if the key is not present.
Discussion:
Be the first person to comment on this question !

Post your comments here:

Your comments will be displayed after verification.