擅长:python、mysql、java
<p>你的问题是你的<code>while</code>循环将在游戏结束时运行,而不是</strong>0,但是在前面的一行中,你将<code>game_over</code>设置为0。你知道吗</p>
<pre><code>game_over = 0
while game_over !=0:
...
</code></pre>
<p>因此,将<code>game_over</code>更改为1,您的代码就可以工作了!你知道吗</p>
<pre><code>def stix(num):
for _ in range(5): print('| '* num)
print
stix(20)
game_over = 1
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>