Project- Game of Tic Tac Toe with Python

9 / 16

Tic Tac Toe with Python - Determine the moves which are legal

Now we will create a function that ensures a move is legal. A move is illegal when a player selects a square which is non-empty.

INSTRUCTIONS
  • Write a function legal_moves as shown below, it returns a list called moves:

    def <<your code goes here>>(board):
        moves = []
        for square in range(NUM_SQUARES):
            if board[square] == EMPTY:
                moves.append(square)
        return <<your code goes here>>
    
See Answer

No hints are availble for this assesment


Note - Having trouble with the assessment engine? Follow the steps listed here

Loading comments...