Python Programming - Dictionaries - Discussion

Discussion Forum : Dictionaries - General Questions (Q.No. 9)
9.
What is the result of the expression dictionary.get('key', 'default')?
Raises a KeyError if 'key' is not present.
Returns the value of 'key' if present, otherwise returns 'default'.
Returns 'default' if 'key' is not present.
Returns a tuple containing 'key' and its value.
Answer: Option
Explanation:
The get() method returns the value for 'key' if present, otherwise returns the specified default value.
Discussion:
Be the first person to comment on this question !

Post your comments here:

Your comments will be displayed after verification.