请稍等 ...
×

采纳答案成功!

向帮助你的同学说点啥吧!感谢那些助人为乐的人

老师能帮我看看我的程序哪里出错了吗?

为什么输入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))

正在回答 回答被采纳积分+3

1回答

7七月 2017-10-02 14:20:41

麻烦把代码格式化一下

0 回复 有任何疑惑可以回复我~
  • 提问者 极客是梦想 #1
    格式化?
    回复 有任何疑惑可以回复我~ 2017-10-03 05:34:08
  • 7七月 回复 提问者 极客是梦想 #2
    就是编辑器有一个 可以按代码规范格式代码的功能,你选一下,你这个都是白色的没有结构我实在看不了。
    回复 有任何疑惑可以回复我~ 2017-10-03 06:41:19
问题已解决,确定采纳
还有疑问,暂不采纳
微信客服

购课补贴
联系客服咨询优惠详情

帮助反馈 APP下载

慕课网APP
您的移动学习伙伴

公众号

扫描二维码
关注慕课网微信公众号