SyntaxFix
Write A Post
Hire A Developer
Questions
>>> import collections >>> D1 = collections.defaultdict(list) >>> for element in L1: ... D1[element[1]].append(element[0]) ... >>> L2 = D1.values() >>> print L2 [['A', 'C'], ['B'], ['D', 'E']] >>>