When I execute (I use the interactive shell), I get these statements:
L=[1,2,3] K=L L.append(4) L [1,2,3,4] K [1,2,3,4]
But when I do the same, replacing L.append (4) with L = L + [4] I get:
L [1,2,3,4] K [1,2,3]
Is this some kind of reference thing? Why is this happening?
Another funny thing that I noticed is that L + = [4] acts as .append, which is odd since I thought it would act as L = L + [4].
Clarification of all of these would be helpful.
thanks
python list append
aitee
source share