I have a dictionary in python
d = {tags[0]: value, tags[1]: value, tags[2]: value, tags[3]: value, tags[4]: value}
imagine that this dict i
tps = [('cat',5),('dog',9),('cat',4),('parrot',6),('cat',6)] from collections import defaultdict dicto = defaultdict(int) for k,v in tps: dicto[k] += v
Result:
>>> dicto defaultdict(, {'dog': 9, 'parrot': 6, 'cat': 15})