【发布时间】:2014-08-07 17:54:14
【问题描述】:
如果我有字典
example = {'cat' : 1, 'dog' : 2, 'cow' : 3, 'horse' : 4}
如何将这些值相加?
我试过了
count = 0
for x in example:
example[x] += count
print example
但这只会打印三遍示例。我该怎么做才能得到 10 作为答案?
【问题讨论】:
-
example声明无效 -
好吧,我的意思是字典哈哈,这只是一个失误
标签: python dictionary