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

bearophileHUGS at lycos.com bearophileHUGS at lycos.com
Fri Jun 2 10:19:15 CEST 2006


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

This is a way:
>>> a = range(10)
>>> del a[:]
>>> a
[]
>>> a.append(20)
>>> a
[20]

Bye,
bearophile




More information about the Python-list mailing list