If Statement Error (Tic Tac Toe)

Fredrik Lundh fredrik at pythonware.com
Wed Nov 2 03:28:05 EST 2005


<ale.of.ginger at gmail.com> wrote:

> The only problem I have is whenever player two goes, it says the cell
> is filled.  But the code:
>
> if gameboard[cell] not in 'OX':
>                gameboard[cell] = 'X'
>            else:
>                print "This cell is already filled."
>                turnnumber = turnnumber - 1
>
> is not any different than the code I am using for player one.  Anything
> I have to change regarding 'OX' or something else?

adding a

    print gameboard[cell]

just before that if-statement is a quick way to check that the cell really
contains the right thing.

</F> 






More information about the Python-list mailing list