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

python dongdonglove8 at hotmail.com
Fri Jun 2 09:58:07 CEST 2006


after del list , when I use it again, prompt 'not defined'.how could i
delete its element,but not itself?
except list.remove(val) ,are there  other ways to delete list 's
elements?

and , I wrote:

list1=[]
def method1():
     global list1
     list1=['a','b','c','d']
def method2():
     list2=list1
     list2.remove['a']
main():
    global list1
     method1()
     method2()
     print list1[0]

it  prints 'b'.


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




More information about the Python-list mailing list