Possible Duplicate:
What does plus equals (+=) do in Python?
I noticed a strange problem:
l1 = ['1', '2', '3']
l2 = l1
item = l2.pop(0)
# the pop operation will effect l1
print l1
l2 = l2 + [item]
# why "l2 = l2 + [item]" does't effect l1 while "l2 += [item]" does.
print l2
print l1
The output is:
['2', '3']
['2', '3', '1']
['2', '3']
But if i change l2 = l2 + [item]
into l2 += [item]
, the output will be:
['2', '3']
['2', '3', '1']
['2', '3', '1']