+ 2
Why b not change its value?
a=[1,[2,3]] b=a[:] a[0]=3 print(b)
2 Answers
+ 2
b will not charge because both a and b are references to different values.If you get confused try to print the id of a and b
print(id(a))
print(id(b))
0
Why it will change
You assigned b =a[:]
Which means b contain the value from beginning to end
and if you want to change value then change value before passing value to b