Why not use a dict
? collections.defaultdict
would work too:
d = defaultdict(list)
for score, student in l:
d[score] += student
solved How to reorganize a list of tuples?
Why not use a dict
? collections.defaultdict
would work too:
d = defaultdict(list)
for score, student in l:
d[score] += student
solved How to reorganize a list of tuples?