Combine dictionaries based on key value
<p>How do I combine the rows of dictionaries having same keys. For instance If I have </p>

<pre><code>my_dict_list = [{'prakash': ['confident']},
 {'gagan': ['good', 'luck']},
 {'jitu': ['gold']},
 {'jitu': ['wins']},
 {'atanu': ['good', 'glory']},
 {'atanu': ['top', 'winner','good']}]
</code></pre>

<p>My objective is to get </p>

<pre><code>my_new_dict_list = [{'prakash': ['confident']},
 {'gagan': ['good', 'luck']},
 {'jitu': ['gold','wins']},
 {'atanu': ['good', 'glory','top', 'winner','good']}]
</code></pre>

<p>How do I do that in Python?</p>

<p>EDIT: The dictionaries in the final list must contain repeated values if present in starting list. </p>

<p>Here's a working example:</p>

<pre><code>from itertools import groupby

my_dict_list = [
    {'prakash': ['confident']},
    {'gagan': ['good', 'luck']},
    {'jitu': ['gold']},
    {'jitu': ['wins']},
    {'atanu': ['good', 'glory']},
    {'atanu': ['top', 'winner']}
]

my_new_dict_list = []
for k, g in groupby(my_dict_list, key=lambda x: sorted(x.keys())):
    ds = list(g)
    d = {}
    for k in ds[0].iterkeys():
        d[k] = sum([d[k] for d in ds], [])
    my_new_dict_list .append(d)

print my_new_dict_list
</code></pre>

python