-
-
Save IndhumathyChelliah/68240135148e0a11e01945ade6b9e51b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from collections import defaultdict | |
#default_factory is not specified. | |
d=defaultdict() | |
d['a']=1 | |
d['b']=2 | |
#default_factory attribute is None. | |
print (d)#Output:defultdict(None, {'a': 1, 'b': 2}) | |
#Returns the default value for key.If not specified raises keyError. | |
#print (d.__missing__('a')) #Output:KeyError: 'a' | |
print (d.__missing__('z'))#Outptu:KeyError: 'z' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment