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

c# - How can I have the VS Debugger break in the correct location for exceptions thrown in Async methods in a Console App? -

php - Issues outputting data after prepared statement with loops -

javascript - How to pass a property by reference -