How do I create many matrices inside a loop statement with python? -


i want create example n matrices like:

m1 = [[0,0],[0,0]] m2 = [[0,0],[0,0]] . .     mn = [[0,0],[0,0]] 

i think work you

res = [[[0 item3 in range(2)] item2 in range(2)] 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 2x2 lists of zeros.


Comments

Popular posts from this blog

Fail to load namespace Spring Security http://www.springframework.org/security/tags -

sql - MySQL query optimization using coalesce -

unity3d - Unity local avoidance in user created world -