我有我的计划一吨的麻烦。过去5个小时我到处寻找,似乎无法找到任何与我正在尝试做的事情有关的事情(无论如何我都能理解)。转换用户字输入价格
我创建一个比萨饼程序,并试图获得大小的输入(如大,中,小)。该程序将要求用户输入大,中,小,价格为空白列表。
我已经设置了价格,但我完全搞不清我需要怎么大,中,小的输入转换成实际的价格,我为大小设置。
这是我的代码。任何帮助是极大的赞赏。我也半知道我不应该使用int来定价,但是我查看的所有命令都是针对Python的老版本或其他东西。
目前使用Python 3.5。
print ("Welcome to My Pizzeria!")
name = input("What name is the order under? ")
size = input("What size would you like? ")
top = input("Would you like to add sausage? ")
money = 0
total = (size+top)
if size == 'large':
total = int(money) + 10.00
elif size == 'medium':
total = int(money) + 7.00
elif size == 'small':
total = int(money) + 5.00
money = total
if top == 'no':
total = int(money) + 0.00
elif top == 'yes':
total = int(money) + 1.00
pass
print ("Your total is $" + str(total))
print ("Thank you for your order " + name + "!")
什么是'money',是基础价格是多少?因为你的情况它被设置为'None',这是不正确的。国际海事组织它应该是一些固定的整数值或者你可能想从用户采取这个输入 –
钱只是我试图测试一些想法。我已经更新了我目前正在玩弄的代码。如果需要更多比萨饼,我必须稍后让我的程序循环。基本上所有我问的是我怎么能做一个伪“if”声明。喜欢:如果回答“你想要什么尺寸”很大,那么总共添加10.00 – Zeus