def clearboard(self)for rowcol in self label keys()self board[row][colempty self label[(rowcol)config(text='similarlypicking moveat least in random modeis simply matter of picking nonempty slot in the board array and storing the machine' mark there and in the gui (degree is the board' size)def machinemove(self)rowcol self pickmove(self board[row][colself machinemark self label[(rowcol)config(text=self machinemarkdef pickmove(self)empties [for row in self degreefor col in self degreeif self board[row][col=emptyempties append((rowcol)return random choice(emptiesfinallychecking for an end-of-game state boils down to inspecting rowscolumnsand diagonals in the two-dimensional list-of-lists board in this schemepytoea tic-tac-toe game widget