Home
Head's Up: I'm in the middle of upgrading my site. Most things are in place, but there are something missing and/or broken including image alt text. Please bear with me while I'm getting things fixed.

Create List of Lists Grid With Empty Values

WARNING : Need to test this, it might be making copies of the same array which would be bad. Or, at least unexpected.

These work for creating lists of lists in a grid that you can access :

python
grid = []

grid_size = 4

for i in range(0, grid_size):
	grid.append([None] * grid_size)

print(grid)
python
grid = []

grid_size = 4

for i in range(0, grid_size):
	grid.append([{"key": "value"}] * grid_size)

print(grid)
txt
[
    [{'key': 'value'}, 
    {'key': 'value'}, 
    {'key': 'value'}, 
    {'key': 'value'}], 
    [{'key': 'value'}, 
    {'key': 'value'}, 
    {'key': 'value'}, 
    {'key': 'value'}], 
    [{'key': 'value'}, 
    {'key': 'value'}, 
    {'key': 'value'}, 
    {'key': 'value'}], 
    [{'key': 'value'}, 
    {'key': 'value'}, 
    {'key': 'value'}, 
    {'key': 'value'}]
]