Removing duplicate keys from python dictionary but summing the values

前端 未结 8 1998
陌清茗
陌清茗 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:52

    Perhapse what you really want is a tuple of key-value pairs.

    [('dog',1), ('cat',2), ('cat',3)]
    

提交回复
热议问题