Create List of Lists Grid With Empty Values

April - 2022

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

grid = []

grid_size = 4

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

print(grid)

grid = []

grid_size = 4

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

print(grid)
[
    [{'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'}]
]