Python Programming - Dictionaries - Discussion

Discussion Forum : Dictionaries - General Questions (Q.No. 38)
38.
What is the purpose of the dictionary.pop(key, default_value) method?
Removes the specified key from the dictionary.
Raises a KeyError if the key is not present.
Removes the specified key and returns its value, or returns the default value if the key is not present.
Adds a new key-value pair with a default value.
Answer: Option
Explanation:
The pop() method with a default value removes the specified key and returns its value, or returns the default value 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.