回答此问题可获得 20 贡献值,回答如果被采纳可获得 50 分。
<p>我花了几个小时试图弄清楚这个问题,但不断出现错误,我不知道如何继续。
基本上,我正在尝试做一个机器人,让你可以在一个越南菜或意大利菜或同类的一个或两个类别的菜。对于我一直坚持的部分,我必须做一个输入函数,这样用户就可以以“[”dish“]的形式键入他们想要的任何食物,然后键入他们想要的任何菜价[”price“]。你知道吗</p>
<hr/>
<p>输出屏幕应该是这样的:(在[]中键入的内容旁边==>;是用户键入的内容)</p>
<ul>
<li>使用以下格式输入列表[“dish”]</li>
</ul>
<pre><code>
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
============================
</code></pre>
<p>显示以下内容:</p>
<pre><code>==================================
v1 - cat
==================================
i1 - cadt
v2 - doh
==================================
i2 - dosh
v3 - dfd
==================================
</code></pre>
<p>当我使用以下代码时</p>
<pre><code>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
</code></pre>