python列出值

mig*_*uel -1 python

我想创建一个列表或字典不确定到目前为止哪些已经工作我需要将文本(用户输入)转换为数值并将它们加在一起有4个可能的答案这就是我希望它如何工作

每个盒子都包含水果,并以不同的价格出售

apple=25,oranges=35,pears=10,bananas=50,pineapple=40
totalprice=0
count=5
list = [box1,box2,box3,box4,box5,]
while count >0:
fruit=raw_input("what fruit is in ")(0)
count -=1
if fruit ==apples:
return "price 25"
totalprice=+25
Run Code Online (Sandbox Code Playgroud)

我希望这次运行五次收集总价

他们在相应的价值中放入的任何水果都将被添加到总价中.对不起,如果没有很好地解释新编程

Gor*_*nek 5

fruits = {"apple":25,"oranges":35,"pears":10,"bananas":50,"pineapple":40}
total_price = 0

for _ in range(0,5):
    fruit = raw_input("Fruit: ")
    if fruit in fruits:
        totalprice += fruits[fruit]

print total_price
Run Code Online (Sandbox Code Playgroud)

这是你想要的吗?要问5次水果,然后打印所有水果的价格总和?