Why does the output for following code differs in python,
>>> A = [1,2,3]
>>> B = A
>>> B += [4]
>>> print A,B
Output: A = [1,2,3,4] , B = [1,2,3,4]
But if we replace B += [4]
to B = B + [4]
the output changes to:
>>> A = [1,2,3] , B = [1,2,3,4]
Please explain.