Today I encountered this strange behavior in Python doing data manipulation. Why changing a will affect b below:
>>> a = ['Hello', 1, 2] >>> b = a >>> a = 5 >>> b [5, 1, 2]
I only asked a to change, why is b changing? But the following is fine,
>>> a = 3 >>> b = 4 >>> a 3 >>> b 4
My guess is that I am doing passing by reference(?). But in both cases are passing by reference, what is going on here?