here's my problem:
Let's say I build a 3x4 matrix:
The first way :
M = []
k=1;
while k<12:
M.append([k,k+1,k+2,k+3])
k=k+4
I get this in output:
0 -> [1, 2, 3, 4]
1 -> [5, 6, 7, 8]
2 -> [9, 10, 11, 12]
Ok great now let's assign some element withM[2][1]=0
0 -> [1, 2, 3, 4]
1 -> [5, 6, 7, 8]
2 -> [9, 0, 11, 12]
OK it works. Now here's the issue with the second way :
lst1=[]
T=[]
for k in range(0,3):
lst1.append(0)
for j in range(0,4):
T.append(lst1)
output: [[0, 0, 0], [0, 0, 0], [0, 0, 0], [0, 0, 0]]
note: The code I have to do is a transpose function hence the dimensions of this matrix
Now let's (try to) assign T[3][0]=4:
output :
0 -> [4, 0, 0]
1 -> [4, 0, 0]
2 -> [4, 0, 0]
3 -> [4, 0, 0]
Nope it changes all the colum instead of the element. Is there a way to make it work properly on the second option ?
I don't understand why it does that. I use python3
Thanks ! A python newbie