Delete all items in the list
peter at www.pjb.com.au
Thu Feb 26 19:08:26 EST 2009
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...
Peter Billam www.pjb.com.au www.pjb.com.au/comp/contact.html
More information about the Python-list