I got confused by the two similar expressions but with different results:
1)
b=[[1,2],[3,4]]
for a in b:
c=a+[5]
a=c
print(b)
2)
b=[[1,2],[3,4]]
for a in b:
c=a+[5]
a[:]=c
print(b)
and the results:
1) [[1, 2], [3, 4]]
2) [[1, 2, 5], [3, 4, 5]]
why using a[:] in for loop would alter the original b list?
thanks in advance :) .. I am very new to Python