Delete all items in the list
Steve Holden
steve at holdenweb.com
Thu Feb 26 19:29:56 EST 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.
regards
Steve
--
Steve Holden +1 571 484 6266 +1 800 494 3119
Holden Web LLC http://www.holdenweb.com/
More information about the Python-list
mailing list