0
Why a and b are not same?
a = [1,[1,2]] b= a[:] a[0] = 3 a[1][1] = 5 print(a) print(b) Output: [3,[1,5]] [1,[1,5]]
1 Answer
+ 7
a[:] is shallow copying . Only reference for outer list is changed . Inner list [1, 2] is pointing to same reference .
If you need to make both list same then just assign a to b, i.e. b=a.