【发布时间】:2022-11-20 08:28:22
【问题描述】:
想要有一个输入变量来问一个问题,其中包含许多合适的 true 语句,但根据用户输入的内容给出不同的答案。我当前的代码与下面类似,但 niot 工作正常。
我只想打印一个语句或另一个。我还想让这种代码组合适用于许多其他答案,比如“也许你有什么?” “有便宜的吗?” “我想要随机的东西!”
我的代码如下所示:
menu_decision = input('would you like to see the menu?') ####input variable for coustmers decision
if 'yes':
print('todays menu: ' + combo_1 + combo_2 + combo_3)
elif 'no':
exit('Have a nice day!')
elif 'what do you have?':
print('todays menu: ' + combo_1 + combo_2 + combo_3)
elif 'I want something random!"
randomizer = input('what is your food preference?')
print('combo shack') ##title of my program
combo_1 = 'FOOD1, ' ###variable 1
combo_2 = 'FOOD2, ' ###variable 2
combo_3 = 'FOOD3 ' ####variable 3
menu_decision = input('would you like to see the menu?') ####input variable for coustmers decision
if menu_decision := 'yes': ####if yes print menu with all three varibles
print('todays menu: ' + combo_1 + combo_2 + combo_3)
#cookie_randomizer= input("how many combos would you like?:")
elif menu_decision := 'no': ###if no dismiss coustmer
exit('Have a nice day!')
【问题讨论】:
标签: python