Duplicated List...

dyo dyo at shinbiro.com
Tue Dec 26 03:54:25 EST 2000


Hi everyone.

>>> a=[1,2,3]
>>> b=[a,10,20,30]
>>> b[0].append('x')
>>> b
[[1, 2, 3, 1, 2, 3, 'x'], 10, 20, 30]
>>> a
[1, 2, 3, 1, 2, 3, 'x']
>>> a.append('xxx')
>>> a
[1, 2, 3, 1, 2, 3, 'x', 'xxx']
>>> b
[[1, 2, 3, 1, 2, 3, 'x', 'xxx'], 10, 20, 30]

Duplicated List work above..


But in this case..

>>> a=[1,1000]
>>> a
[1, 1000]
>>> b
[[1, 2, 3, 1, 2, 3, 'x', 'xxx'], 10, 20, 30]
>>>

Why do not change List 'b' ?
What happen List 'b' ?






More information about the Python-list mailing list