我怎样才能解决这个问题?你知道吗
pricec = {
"Case" : 56950,
"PSU" : 48950,
"Mobo" : 59500,
"GPU" : 124990,
"Memory" : 57800,
"CPU" : 53900,
"SSD" : 99900,
"Cooling" : 0
}
total = 0
def pricet(total, pricec):
for x in pricec:
total += pricec[x]
return total
pricet(total, pricec)
print ("Build Cost: " + str(total)+"kr")
您没有从
pricet()
函数的返回值设置total变量。你知道吗此外,还有一种比循环更简单的方法来求字典值的和:
相关问题 更多 >
编程相关推荐