File tree Expand file tree Collapse file tree 1 file changed +4
-2
lines changed Expand file tree Collapse file tree 1 file changed +4
-2
lines changed Original file line number Diff line number Diff line change @@ -40,7 +40,7 @@ def playAgain():
4040 return input ().lower ().startswith ('y' )
4141
4242def makeMove (board , letter , move ):
43- if board [ move ] == ' ' :
43+ if isSpaceFree ( board , move ) :
4444 board [move ] = letter
4545 else :
4646 raise Exception ("makeMove: the field is not empty!" )
@@ -68,7 +68,7 @@ def getBoardCopy(board):
6868
6969def isSpaceFree (board , move ):
7070 # Return true if the passed move is free on the passed board.
71- return board [move ] == ' '
71+ return board [move ]. isdigit ()
7272
7373def getPlayerMove (board ):
7474 # Let the player type in his move.
@@ -141,6 +141,8 @@ def main():
141141 while True :
142142 # Reset the board
143143 theBoard = [' ' ] * 10
144+ for i in range (9 ,0 ,- 1 ):
145+ theBoard [i ] = str (i )
144146 playerLetter , computerLetter = inputPlayerLetter ()
145147 turn = whoGoesFirst ()
146148 print ('The ' + turn + ' will go first.' )
You can’t perform that action at this time.
0 commit comments