Delete all items in the list
steve at holdenweb.com
Fri Feb 27 01:29:56 CET 2009
Peter Billam wrote:
> On 2009-02-26, Clarendon <jineu21 at hotmail.com> wrote:
>> Hi. This must be a simple command but I just can't find it in the
>> Phthon manual. How do I delete all items with a certain condition from
>> a list? For instance: > L=['a', 'b', 'c', 'a']
>> I want to delete all 'a's from the list. > But if L.remove('a')
>> only deletes the first 'a'. How do you delete all 'a's?
> L2 = list(set(L))
> works for me...
I have to wonder for what value of "works" this works.
The simplest problem is it doesn't remove all the "a"s.
Steve Holden +1 571 484 6266 +1 800 494 3119
Holden Web LLC http://www.holdenweb.com/
More information about the Python-list