If Statement Error (Tic Tac Toe)

Mike Meyer mwm at mired.org
Wed Nov 2 01:35:31 CET 2005

ale.of.ginger at gmail.com writes:

> Nevermind my previous reply: I've been fixing up the code and
> understand it.  I'm at a nifty 80 lines where I am at now rather than
> 209 lines in the previous version!  The changes are immense!
> 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?

Make sure you're setting cell properly - you didn't show that.

Also, the above code is a syntax error; I assume your running code has
the correct indentation.

Mike Meyer <mwm at mired.org>			http://www.mired.org/home/mwm/
Independent WWW/Perforce/FreeBSD/Unix consultant, email for more information.

More information about the Python-list mailing list