how can i copy a sublist

Daniel Orlowski daniel.orlowski at bg-sys.de
Thu Mar 1 08:19:43 EST 2001


Hi,

i try to copy a sublist from list "a" to list "b". After that i alter a
value in "b" and oops! value in "a" is also altered.
so it looks like that:
>>> a=[[1,2],[3,4]]
>>> b=[]
>>> b.append(a[0])
>>> b
[[1, 2]]
>>> b[0][0]=3
>>> a
[[3, 2], [3, 4]]

how can i copy a sublist without
"get_a_value_from_a_list_and_put_it_into_another"

Regards,
Daniel





More information about the Python-list mailing list