<p>我正在做一个简单的游戏,有2名玩家和20支棍子给。每位玩家可以选择1-3根棍子,选择最后一根棍子的玩家将输掉比赛。你知道吗</p>
<pre><code>def stix(num):
for _ in range(5): print('| '* num)
print
stix(20)
game_over = 0
while game_over !=0:
players={}
for i in range(2):
players[i] = int(input('Player %d: Please pick stick(s) up to 3' %i))
if players > 3 or players<0:
print('Please pick between 1 - 3 stick(s)')
else:
stix-=players
if stix <= 0:
print('Player[i] lost')
break
else:
print('There is %d stick(s) left' %stix)
print(stix-players[i])
</code></pre>
<p>所以,函数<code>stix</code>显示了20根棍子,就这样。它不要求<code>please pick stick(s) up to 3</code>。我错过了什么?你知道吗</p>
<p>*我使用的是python 2.6</p>
<p>提前谢谢!你知道吗</p>
<p>你永远不会进入while循环:</p>
<pre><code>game_over = 0
while game_over !=0: # Evaluated to false the first time so it's skipped.
# code
</code></pre>
<p>因此,在本例中,错误与<code>input()</code>无关</p>