xxxxxxxxxx
users = [
{'name': 'John', 'surname': 'Red', 'age': 27},
{'name': 'Kate', 'surname': 'Green', 'age': 40},
{'name': 'Jack', 'surname': 'Brown', 'age': 32}
]
xxxxxxxxxx
list_of_dict = []
for row in list_of_list[1:]: # Taking 0 index as header or key and rest as value
list_of_dict.append({key: val for key, val in list(zip(*[list_of_list[0], row]))})
xxxxxxxxxx
a = [10,20,30]
b = [100,200,300]
my_dictionary = dict(a=a, b=b)
xxxxxxxxxx
In [1]: import collections
:
l = [{'a':1},{'b':2}] :
d = dict(collections.ChainMap(*l)) :
In [2]: d
Out[2]: {'b': 2, 'a': 1}