Need help with a two-dimensional array

What you’ve bumped into here, David, is one of Python’s fundamentals: Python defaults to treating almost everything as an object. As bowlOfRed mentioned, the ’ * ’ operator replicates list objects. Your value assignment affects all rows because the first list is a reference to a [ [0] * 9 ] 'list of zeroes' object..

The second dimension of your 2-dimensional list is a list of references to the first list of zeroes. One would expect that the rows would be separate instances but they aren’t. This is an interesting feature of Python but can take some getting used to, to say the least.

The elements in the first list object are values (and not objects) because ‘0’ is a pure value, not an object. In other words, this first list is a list of independent instances of the value ‘0’.

This will create a list of independent items in a 9x9 array that you can address individually:

ballField = [[0 for x in range(9)] for y in range(9)]
ballField[1][3] = 1   # note that the coordinates are [Y][X] with top left origin.

The above is a refactored version of BowlOfRed’s code using explicit references so that the parts are more evident.
You’ve no doubt noticed that list indices are Zero-based.

Lists have some interesting behaviors that you can leverage, like using a negative index to wrap around backward starting from the end (in which case, ‘[-1]’ indexes to the last item since the first item is ‘[0]’).

for row in range(len(ballField)):   # prints the ballfield in a square layout.
    print(ballField[row])