我正在尝试运行下面的Python并期望最后一项证明是真的。我正在寻找啤酒,看它是否存在于菜单中,但我变得虚假。我在这里缺少什么?
res = '.'.join(i+'.'+j for i, j in zip(test, test.values[0]))
我的输出如下
# [] print 3 tests, with description text, testing the menu variable for 'pizza', 'soup' and 'dessert'
menu = "salad, pasta, sandwich, pizza, drinks, dessert, soda, beer"
print("pizza is in the menu =", 'pizza' in menu)
print("soup is in the menu =", 'soup' in menu)
print("dessert is in the menu = ", 'dessert' in menu)
print("beer is in the menue = ", 'beer' in menu)
#now asking for a user to search an item
menu_ask = input("Type an item to see if it is in the menu: ")
print(menu_ask,"is in the menu = ", 'menu_ask'.lower() in menu.lower())
为什么最后一项不是真的?我怎样才能让它成为真的?
答案 0 :(得分:0)
print(menu_ask,"is in the menu = ", 'menu_ask'.lower() in menu.lower())
不接受变量 menu_ask ,而是字符串" menu_ask",它不在菜单中
将其更改为:
print(menu_ask,"is in the menu = ", menu_ask.lower() in menu.lower())
它应该按预期工作