def winner(board):
    """
    Returns the winner of the game, if there is one.
    """
    # Check vertical
    for row in range(3): 
        if board[row][0] == board[row][1] and board[row][1] == board[row][2]:
            return board[row][0]

    # Check horizontal
    for col in range(3): 
        if board[0][col] == board[1][col] and board[1][col] == board[2][col]:
            return board[0][col]

    # Check diagonals
    if board[0][0] == board[1][1] and board[1][1] == board[2][2]:
        return board[0][0]
    if board[2][0] == board[1][1] and board[1][1] == board[0][2]: 
        return board[2][0]
    
    return None