我自己 diy 了一个饮品店系统可出现错误,希望能来帮帮我
goods=['1.卡布奇诺\n','2.拿铁\n','3.猫屎咖啡\n','4.可乐\n','5.雪碧\n','6.芬达\n','7北冰洋\n','8.鲜榨果汁',]
print('欢迎来到米其林自主饮品店qwq')
print('本店周六日打7折呦')
print('本店的饮品有',goods)
print('请问您想要什么饮料呢?(请输入产品序号)')
needs=int(input())
while true:
if needs==1:
payneeds=14# <==报错说这应是缩进块
elif needs==2:
payneeds=15
elif needs==3:
payneeds=30
elif needs==4:
payneeds=4
elif needs==5:
payneeds=3
elif needs==6:
payneeds=4
elif needs==7:
payneeds=5
else needs==7:
payneeds=10
payneeds=int(needs*0.7)
print('原价',needs,'元')
错误1(^):缩进没加
错误2:input会把输入的内容变成字符串,如果你这样写的话,逻辑就会变成:“把needs0.7的值变为数字,而不是把needs变为数字之后乘0.7”你这个应该改int(needs)0.7
正确代码:
供参考