Removing duplicate keys from python dictionary but summing the values

前端 未结 8 2090
陌清茗
陌清茗 2021-01-15 05:30

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

8条回答
  •  梦谈多话
    2021-01-15 05:54

    I'm not sure what you're trying to achieve, but the Counter class might be helpful for what you're trying to do: http://docs.python.org/dev/library/collections.html#collections.Counter

提交回复
热议问题