1

I want to create for example n matrices like:

m1 = [[0,0],[0,0]]
m2 = [[0,0],[0,0]]
.
.    
mn = [[0,0],[0,0]]
dcalmeida
  • 393
  • 7
  • 18

1 Answers1

2

I think that will work for you

res = [[[0 for item3 in range(2)] for item2 in range(2)] for item1 in range(10)]
print res

Output:

[
 [[0, 0], [0, 0]],
 [[0, 0], [0, 0]],
 [[0, 0], [0, 0]],
 [[0, 0], [0, 0]],
 [[0, 0], [0, 0]],
 [[0, 0], [0, 0]],
 [[0, 0], [0, 0]],
 [[0, 0], [0, 0]],
 [[0, 0], [0, 0]],
 [[0, 0], [0, 0]]
]

Basically 10(your n value) arrays with 2x2 lists of zeros.

omri_saadon
  • 10,193
  • 7
  • 33
  • 58