我花了几个小时试图弄清楚这个问题,但不断出现错误,我不知道如何继续。 基本上,我正在尝试做一个机器人,让你可以在一个越南菜或意大利菜或同类的一个或两个类别的菜。对于我一直坚持的部分,我必须做一个输入函数,这样用户就可以以“[”dish“]的形式键入他们想要的任何食物,然后键入他们想要的任何菜价[”price“]。你知道吗
输出屏幕应该是这样的:(在[]中键入的内容旁边==>;是用户键入的内容)
Lists should have at least 1 dish and not more than 10 dishes
Lists with prices correspond exactly to lists with dishes
Execute with new lists (n) or original lists (o)? ==> n
List of Vietnamese dishes ==> ["water", "rice", "pancake", "steamed sticky rice"]
List of Vietnamese dishes prices ==> [7.5, 6.75, 5.15, 8.25]
List of Italian dishes ==> ["pizza", "meatball spaghetti", "pasta"]
List of Italian dishes prices ==> [7.15, 6.25, 5.0]
*** TRACE Vietnamese ['Pho', 'Fried rice', 'Pancake', 'Steamed sticky rice'] [7.5, 6.75, 5.15, 8.25]
*** TRACE Italian ['Pizza', 'Meatball spaghetti', 'Pasta'] [7.15, 6.25, 5.0]
Order a dish? y/n ==> (y)
All the available dishes are
============================
v1 ‐ Pho
v2 ‐ Fried rice
v3 ‐ Pancake
v4 ‐ Steamed sticky rice
============================
i1 ‐ Pizza
i2 ‐ Meatball spaghetti
i3 ‐ Pasta
============================
显示以下内容:
==================================
v1 - cat
==================================
i1 - cadt
v2 - doh
==================================
i2 - dosh
v3 - dfd
==================================
当我使用以下代码时
if (1 < a < 10 and 1 < b <10):
for i in range(1,a+1) and range(1,b+1):
print("v"+str(i)," -", vietnamese_dishes[i-1])
print("\n==================================\n")
print("i"+str(i)," -", italian_dishes[i-1])
print("\n\nPlease choose another dish by indicating the code that we provide")
print("\nYou may order the same dish as before, if you want")
print("\nIf you do not choose an existing dish we will choose one for you")
return
将
dish_codeslist
中的第二个if
语句更改为:编辑:
编辑2:
编辑3:
将这段代码添加到您的代码中,并尝试运行它以查看它是否满足您的需求。在这段代码中,用户输入的处理(无论他们是否从任何类别输入菜)将被添加到一个新的列表中。你知道吗
此代码可能有助于解决您的问题,请首先尝试在新的python文件中运行它
相关问题 更多 >
编程相关推荐