python merge list of dictionaries no duplicates code example
Example 1: merge a list of dictionaries python
>>> from collections import ChainMap
>>> a = [{'a':1},{'b':2},{'c':1},{'d':2}]
>>> dict(ChainMap(*a))
{'b': 2, 'c': 1, 'a': 1, 'd': 2}
Example 2: python convert two lists with duplicates to dictiona
{'a': [1, 2], 'd': [4], 'c': [3]}