Python tutorial
Dictionary is a mapped data structure, which has key:value pair as an elements, key is immutable object, values can be mutable
Various Ways to create a Dictionary object in Python
method | description |
dict() | create a empty dictionary object |
dict(mapping) | create a dictionary from mapping |
dict(iterable) | create a dictionary from iterable |
dict(**kwargs) | create a dictionary from key word args |
>>> d={} >>>d=dict()
d=dict(mapping)
>>>def fn(key,value): return key,int(value) d=dict(map(fn,'abcdef','123456'))
d=dict( [('a',1),('b',2),('c',3),('d',4),('e',5),('f',6)] )
>>>d = dict(one=2,two=3,three=4,four=5,five=6)
ADS