I'm confident there's a succinct pythonic way to convert:
[('a', 1), ('a', 2), ('b', 4)]
Into:
{'a':[1, 2], 'b':[4]}
I've tried various combinations of zip
, dict
, and itertools.groupby
and I can't get my head round how to do this.
I'm confident there's a succinct pythonic way to convert:
[('a', 1), ('a', 2), ('b', 4)]
Into:
{'a':[1, 2], 'b':[4]}
I've tried various combinations of zip
, dict
, and itertools.groupby
and I can't get my head round how to do this.