mercredi 8 avril 2020

Python error: NoneType' object is not subscriptable

I got this problem and I spent 2 days trying to resolve it with no success, would you please help me

This is the error

if board[i][j] != ttt.EMPTY:
TypeError: 'NoneType' object is not subscriptable

And this is the essential part of the code:

X = "X"
O = "O"
EMPTY = " "
def initial_state():
    """
    Returns starting state of the board.
    """
    initial_state= [[EMPTY, EMPTY, EMPTY],
            [EMPTY, EMPTY, EMPTY],
            [EMPTY, EMPTY, EMPTY]]

board = ttt.initial_state()

if board[i][j] != ttt.EMPTY:

Thank you

Aucun commentaire:

Enregistrer un commentaire