这是我目前的代码:
row1 = ["","",""]
row2 = ["","",""]
row3 = ["","",""]
def gameTime ()
print ( row1[0], row1[1], row1[2] )
print ( row2[0], row2[1], row2[2] )
print ( row3[0], row3[1], row3[2] )
while True:
player1Row = input ( "Select a row: " )
player1Column = input ( "Select a column: " )
if player1Row == 1 and player1Column == 1:
if row1[0] !="X" and row1[0] !="O":
row1 [0] = "X"
gameTime ()
我尝试了几种不同的策略,使用.append()甚至.remove(),然后使用.append()替换列表索引项[0],但没有效果。我觉得我遗漏了一些东西,因为如果我将列表项的值设置为0,1,2而不是“”的话,它是有效的,但我希望现在就这样做,以便完成游戏。如有任何建议,我们将不胜感激。谢谢你的时间!你知道吗
player1Row
和player1Column
属于str
类型。你知道吗但是,列表索引是,应该是
int
而不是str
类型的需要将输入的返回转换为
int
相关问题 更多 >
编程相关推荐