Simple del[] list question
Matthew Hirsch
meh9 at cornell.edu
Wed Apr 26 13:25:16 EDT 2000
Hi All,
What is going on here?
This leaves a intact.
>>> a=[[1,2,3],[4,5,6]]
>>> b=a[:]
>>> del b[0]
>>> b
[[4, 5, 6]]
>>> a
[[1, 2, 3], [4, 5, 6]]
This also changes a.
>>> a=[[1,2,3],[4,5,6]]
>>> b=a[:]
>>> del b[0][0]
>>> b
[[2, 3], [4, 5, 6]]
>>> a
[[2, 3], [4, 5, 6]]
Why did a change? Why suddenly when you go to two dimensions does the
behavior change?
Thanks,
Matt
More information about the Python-list
mailing list