How can I turn a list of dicts like [{'a':1}, {'b':2}, {'c':1}, {'d':2}]
, into a single dict like {'a':1, 'b':2, 'c':1, 'd':2}
?
Answers here will overwrite keys that match between two of the input dicts, because a dict cannot have duplicate keys. If you want to collect multiple values from matching keys, see How to merge dicts, collecting values from matching keys?.