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

来源: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

麻烦把代码格式化一下

0
2
7七月
回复
极客是梦想
就是编辑器有一个 可以按代码规范格式代码的功能,你选一下,你这个都是白色的没有结构我实在看不了。
2017-10-03
共2条回复

Python3.8系统入门+进阶 (程序员必备第二语言)

语法精讲/配套练习+思考题/原生爬虫实战

14598 学习 · 4470 问题

查看课程