This dict()
function returns a dictionary object i.e. it converts an object into a python dictionary.
dict([**kwargs])
dict([mapping, **kwargs])
dict([iterable, **kwawrgs])
Here,
**kwargs
let you take an arbitrary number of keyword arguments.>>> dict(a=1, b=2)
{'a': 1, 'b': 2}
# Without Keyword arguments
>>> dict([('a', 1), ('b', 2)])
{'a': 1, 'b': 2}
>>> # Passing Keyword arguments also
>>> dict([('a', 1), ('b', 2)], c=3)
{'a': 1, 'b': 2, 'c': 3}
>>> # Using iterable, zip() creates an iterable
>>> dict(zip(['a', 'b', 'c'], [1, 2, 3]))
{'a': 1, 'b': 2, 'c':
>>> dict({'a': 1, 'b': 2})
{'a': 1, 'b': 2}
>>> # Passing keyword arguments also
>>> dict({'a': 1, 'b': 2}, c=3)
{'a': 1, 'b': 2, 'c': 3}