I am using Python 3.4.
I noticed this curious behaviour:
In [1]: a=[1,2,3,4,5,6,7,8,9]
In [2]: b=[10,11,12,13,14,15,16,17,18,19]
In [3]: type(a)
Out[3]: list
In [4]: a
Out[4]: [1, 2, 3, 4, 5, 6, 7, 8, 9]
In [5]: b
Out[5]: [10, 11, 12, 13, 14, 15, 16, 17, 18, 19]
In [6]: c=a
In [7]: c
Out[7]: [1, 2, 3, 4, 5, 6, 7, 8, 9]
In [8]: c.extend(b)
In [9]: c
Out[9]: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19]
In [10]: a
Out[10]: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19]
Why is a
modified by the extend method applied on c
?
Do you observe the same behaviour?
Is it normal? And in this case, how can I extend c
leaving a
intact?