Question: I have this list of dictionaries:

```
list_of_ds = [
    {'a': [1, 2], 'b': [4, 5], 'c': [6, 7]},
    {'a': [4], 'b': [56], 'c': [46]},
    {'a': [92], 'b': [65], 'c': [43]}
]

```

and I want this as output:

```
{'a': [1, 2, 4, 92], 'b': [4, 5, 56, 65], 'c': [6, 7, 46, 43]}

```

Until now ...

I tried

```
d_of_ds = reduce(lambda d1, d2: d1.update(d2), list_of_ds)

```

gives: `AttributeError: 'NoneType' object has no attribute 'update'`

I tried

```
d_of_ds = reduce(lambda d1, d2: d1.update(d2) or d1, list_of_ds, {})

```

Overwrites each iteration: `{'a': [92], 'b': [65], 'c': [43]}`

I tried

```
d_of_ds = {k: v for d in list_of_ds for k, v in d.items()}

```

Overwrites each iteration: `{'a': [92], 'b': [65], 'c': [43]}`

Answer: 
Not-so-efficient but pretty [`reduce`](https://docs.python.org/3/library/functools.html#functools.reduce) solution:

```
def f(x, y):
    return {k: x.get(k, []) + y.get(k, []) for k in set(x).union(y)}

from functools import reduce
reduce(f, list_of_ds) # {'b': [4, 5, 56, 65], 'a': [1, 2, 4, 92], 'c': [6, 7, 46, 43]}

```

Not-so-pretty but efficient solution using [`collections.defaultdict`](https://docs.python.org/3/library/collections.html#collections.defaultdict):

```
from collections import defaultdict

def f(list_of_ds):
    new = defaultdict(list)
    for d in list_of_ds:
        for k, v in d.items():
            new[k].extend(v)
    return new # or dict(new), to obtain a 'dict' object

f(list_of_ds) # {'a': [1, 2, 4, 92], 'b': [4, 5, 56, 65], 'c': [6, 7, 46, 43]}

```
without importing any library 

```
>>> new_dict = {}
>>> new_dict
{}
>>> for dct in list_of_ds:
        for key,val in dct.items():
            if key not in new_dict.keys(): new_dict[key] = val
            else: new_dict[key].extend(val)

>>> new_dict
{'a': [1, 2, 4, 92], 'c': [6, 7, 46, 43], 'b': [4, 5, 56, 65]}

```