[Tutor] could someone explain why this happens to me.

sphennings W. sphennings at gmail.com
Sat Mar 7 20:09:35 CET 2009


When I enter the following code into IDLE  do both lists have the same value?
How would I manipulate both lists separately?

>>> List1=[1,2,3]
>>> List2=List1
>>> List2.reverse()
>>> print(List2)
[3, 2, 1]
>>> print(List1)
[3, 2, 1]
>>> List2.append(0)
>>> print(List2)
[3, 2, 1, 0]
>>> print(List1)
[3, 2, 1, 0]


More information about the Tutor mailing list