-
-
Save IndhumathyChelliah/fd5cb4905fd5f1b1558f65b74c2d1f59 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 mentioned | |
d=defaultdict() | |
d['a']=1 | |
d['b']=2 | |
print (d)#Output:defaultdict(None, {'a': 1, 'b': 2}) | |
print (d['a'])#Output:1 | |
# key 'c' doesn't exists in the dictionary,it raises KeyError | |
print (d['c'])#Output:KeyError: 'c' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment