1x = [[foo for i in range(10)] for j in range(10)]
2# x is now a 10x10 array of 'foo' (which can depend on i and j if you want)
3
1# Using above second method to create a
2# 2D array
3rows, cols = (5, 5)
4arr = [[0 for i in range(cols)] for j in range(rows)]
5print(arr)
6
1o=[]
2for i in range(0,rows):
3 x=[]
4 for j in range(0,cols):
5 x.append(0)
6 o.append(x)
7#if you use [[0]*cols]*rows all rows will become the same list
8#so editing in one row will edit all rows