所以我已经试过运行我的代码了,这一直在给我一个错误。我需要计算总股票价值,但我对前进的方向感到困惑和困惑。
#a list of items in a cafe
cafeMenu = ["coffee, muffins, cake, tea"]
#a dictionary with integer keys
intKeys_stockDict = {coffee: '12'
muffins: '9'
cake: '10'
tea: '8'
}
#a dictionary with keys
int_ Keys_priceDict = {coffee: '15'
muffins: '12'
cake: '11'
tea: '10'
}
def totalstock(stockworth):
答案 0 :(得分:0)
#a list of items in a cafe
cafeMenu = ["coffee", "muffins", "cake", "tea"]
intKeys_stockDict = {"coffee": 12,
"muffins": 9,
"cake": 10,
"tea": 8
}
int_Keys_priceDict = {"coffee": 15,
"muffins": 12,
"cake": 11,
"tea": 10
}
totalstock = 0
for item in cafeMenu:
totalstock += intKeys_stockDict[item]*int_Keys_priceDict[item]
print(totalstock)