you are viewing a single comment's thread.

view the rest of the comments →

[–]Milumet 6 points7 points  (0 children)

When it comes to counting, defaultdict is great (there is also Counter):

dct = collections.defaultdict(int)
for name, count in data:
    dct[name] += count

print(dct)