[Tutor] Question on List of Dict
Sunil Tech
sunil.techspk at gmail.com
Fri Sep 19 08:53:51 CEST 2014
Hi all,
tes = [{'a': 1, 'b': 'this', 'c': 221},
{'a': 2, 'b': 'this', 'c': 215},
{'a': 1, 'b': 'is', 'c': 875},
{'a': 1, 'b': 'sentence', 'c': 874},
{'a': 2, 'b': 'another', 'c': 754},
{'a': 2, 'b': 'word', 'c': 745}]
The above one is the result form the DB. I am trying to convert it to
something like
result_tes = [{'a': 1, 'b': 'this, is, sentence', 'c': '221, 875, 874'},
{'a': 2, 'b': 'this, another, word', 'c': '215, 754, 744'}]
if the value of the 'a' is same, then all those other values of the dict
should be merged/clubbed.
I tried, but it became complex and complex.
please can any one help me to get the result.
Thanks,
Sunil. G
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20140919/d53fce89/attachment.html>
More information about the Tutor
mailing list