老师能帮我看看我的程序哪里出错了吗?
来源:4-1 列表的定义

极客是梦想
2017-10-02
为什么输入tea的时候 还会进行 coffee的flavoring呢?
name = input("Please enter your name: ")
type = input("Please enter the name of beverage(coffee of tea) you want: ")
cost1 = 0
cost2 = 0
if type == "tea" or type == "t":
size = input("Please enter the size of your beverage: ")
if size == "small":
print("small")
cost1 = 1.50
elif size == "medium":
print("small")
cost1 = 2.50
elif size == "large":
print("large")
cost1 = 3.25
else:
cost1 = 0
flavoring = input("Please enter what would you like to add(none,lemon,or mint): ")
if flavoring == "none":
print("no flavoring")
cost2 = 0
elif flavoring == "lemon":
print("lemon")
cost2 = 0.25
elif flavoring == "mint":
print("mint")
cost2 = 0.50
else:
cost2 = 0
if type == "coffee" or "c":
size = input("Please enter the size of your beverage: ")
if size == "small":
print("small")
cost1 = 1.50
elif size == "medium":
print("medium")
cost1 = 2.50
elif size == "large":
print("large")
cost1 = 3.25
else:
cost1 = 0
flavoring = input("Please enter what would you like to add(none,vanilla,chocolate,or maple): ")
if flavoring == "none":
print("no flavoring")
cost2 = 0
elif flavoring == "vanilla":
print("vanilla")
cost2 = 0.25
elif flavoring == "chocolate":
print("chocolate")
cost2 = 0.75
elif flavoring == "maple":
print("maple")
cost2 = 0.50
else:
cost2 = 0
cost = ((cost1+cost2)*1.11)
fcost = round(cost,2)
print("Hello {}, your order is a {} {} with {}, cost:${}".format(name,size,type,flavoring,fcost))
1回答
-
7七月
2017-10-02
麻烦把代码格式化一下
022017-10-03
相似问题