Claudio Grondi wrote: > > Another approach as already proposed could be, that you define your grid > as a dictionary in a following way: > grid = {} > for column in range(1,10): > for row in range(1,10): > grid[(column, row)] = None > # then you can refer to the cells of the 'array' like: > colNo=5; rowNo=4 > valueInCellOfGrid = grid[(colNo, rowNo)] > # and set them like: > grid[(colNo, rowNo)] = 9 > print valueInCellOfGrid > print grid[(colNo, rowNo)] >
FWIW, if you leave out the parentheses, it looks more like a genuine 2D array, which can be nice (actually I think it's the main advantage over lists of lists): print grid[colNo, rowNo] > > Claudio --Max -- http://mail.python.org/mailman/listinfo/python-list