after del list , when I use it again, prompt 'not defined'.how could i delete its element,but not itself?

Duncan Smith buzzard at urubu.freeserve.co.uk
Fri Jun 2 09:11:28 EDT 2006


python wrote:

[snip]

> 
> How could I keep the list1 not to change when remove list2's elements?
> 

You can't when the names list1 and list2 refer to the same list.  Try
making list2 a copy of list1,

list2 = list(list1)

Duncan



More information about the Python-list mailing list