# List manipulation after using list comprehension and list multiplied by integer

m=[[0]*5]*5
m
[[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]]

n=[[0 for i in range(5)] for i in range(5)]
n==m
True

n[2][2]=1
n
[[0, 0, 0, 0, 0], [0, 0, 0, 0, 0], [0, 0, 1, 0, 0], [0, 0, 0, 0, 0], [0, 0, 0, 0, 0]]

m[2][2]=1
m
[[0, 0, 1, 0, 0], [0, 0, 1, 0, 0], [0, 0, 1, 0, 0], [0, 0, 1, 0, 0], [0, 0, 1, 0, 0]]

n==m
False

Why am i not getting same result ?
why m[2][2]=1 yield [[0, 0, 0, 0, 0], [0, 0, 0, 0, 0], [0, 0, 1, 0, 0], [0, 0, 0, 0, 0], [0, 0, 0, 0, 0]] ??

not much familiar with python but i think m is making something like invisible sub-arrays (`[0]*5`) of 0’s in a array list for five for 5 times and n is making arrays of 5 zeros for five times . so when you do `n[2][2]=1` it inserts in the 2nd element of 2nd arr in the arr of list and `m[2][2]=1` it inserts in each element in sub arr in the arr of list .

why m[2][2]=1 yield [[0, 0, 0, 0, 0], [0, 0, 0, 0, 0], [0, 0, 1, 0, 0], [0, 0, 0, 0, 0], [0, 0, 0, 0, 0]] ??

because

[[0, 0, 0, 0, 0],- this is in position 0 in the arr
[0, 0, 0, 0, 0], - this is in position 1 in the arr
[0, 0, 1, 0, 0], - this is in position 2 in the arr and 1 is in pos 2 in the sub array
[0, 0, 0, 0, 0], - this is in position 3 in the arr
[0, 0, 0, 0, 0]] -this is in position 4 in the arr