Open this example in the interactive library
Source code
grid = [[0] * 3 for _ in range(2)]
grid[0][1] = 7
print(grid)Sample output
[[0, 7, 0], [0, 0, 0]]

Build two independent lists instead of repeating one in Python.
Open this example in the interactive library
grid = [[0] * 3 for _ in range(2)]
grid[0][1] = 7
print(grid)[[0, 7, 0], [0, 0, 0]]