how to clear up a List in python?

Fredrik Lundh fredrik at pythonware.com
Thu May 25 15:39:03 EDT 2006


vbgunz wrote:

>> I have new a list , when it hava large number of values, I wonna to
>> delete all the values in it,how to do?
> 
> something like this will probably help.
> 
> x = [1,2,3,4,5,6,7,8,9]
> y = x
> 
> list([x.pop() for z in xrange(len(x))])
> 
> print x, y  # [] []

if you don't know how to do things, you don't need to post.

if you know why this is about the dumbest way to do what you're doing, 
and you're posted this on purpose, you really need to grow up.

</F>




More information about the Python-list mailing list