Create dictionary from fromkeys() function : fromkeys « Dictionary « Python Tutorial






print {}.fromkeys('xyz')
print {}.fromkeys(('love', 'honor'), True)

# More Than One Entry per Key Not Allowed

dict1 = {' foo':789, 'foo': 'xyz'}
print dict1
dict1['foo'] = 123
print dict1








8.9.fromkeys
8.9.1.fromkeys method creates a new dictionary with the given keys, each with a default corresponding value of None
8.9.2.If you don't want to use None as the default value, you can supply your own default
8.9.3.get method is a way of accessing dictionary items.
8.9.4.You may supply your own "default" value
8.9.5.Create dictionary from fromkeys() function