rhodri at wildebst.demon.co.uk
Sun Sep 27 21:46:14 CEST 2009
On Sun, 27 Sep 2009 17:40:57 +0100, Someone Something
<fordhaivat at gmail.com> wrote:
> I'm trying to write a little tic-tac-toe program I need a array/list such
> that I can represent the tic tac toe board with an x axis and y axis and
> can access each square to find out whether there is an X or an O. I have
> absolutely no idea how to do this in python and I really, really, don't
> to do this is C.
A list of lists.
>>> board = [[None, None, None], [None, None, None], [None, None, None]]
>>> board = 'X'
>>> print board
Just be a little careful constructing your board. It's awfully easy to
end up with rows being the same list object if you're careless, and then
unexpected things happen :-)
Rhodri James *-* Wildebeest Herder to the Masses
More information about the Python-list