2d array python initialize

x = [[foo for i in range(10)] for j in range(10)]
# x is now a 10x10 array of 'foo' (which can depend on i and j if you want)

Here is what the above code is Doing:
1. Create an empty list, x.
2. For each row in the 2D array, append a list of the same length to x.
3. For each element in each row, set the element to the value of foo.

Note that the list comprehension is creating a list of lists, so x is a list of lists.