I'm trying to create a multidimensional array. First I wanted to put all the first elements with value 2 so I did:
l=4
x=6
TSup=[ [ 2 for i in range(l) ] for j in range(x) ]
print TSup
And I got what I expected:
[[2, 2, 2, 2], [2, 2, 2, 2], [2, 2, 2, 2], [2, 2, 2, 2], [2, 2, 2, 2], [2, 2, 2, 2]]
Now I want to change the code so that the 1st value is the respective position of a Test list, that is, I wanted the 1st element to be 290, the 2nd 293, the 3rd 291 and the 4th 294, so I changed the following form:
Test=[290,293,291,294]
l=4
x=6
for a in range(len(Test)):
TSup=[ [ Test[a] for i in range(l) ] for j in range(x) ]
print (TSup)
but does not give the expected, only gives the value for the last iteration, 4th position:
[[294, 294, 294, 294], [294, 294, 294, 294], [294, 294, 294, 294], [294, 294, 294, 294], [294, 294, 294, 294], [294, 294, 294, 294]]
And I wanted to:
[[290, 293, 291, 294],[290, 293, 291, 294],[290, 293, 291, 294],[290, 293, 291, 294],[290, 293, 291, 294],[290, 293, 291, 294]]
If someone can help me, I really appreciate it!