how to remove multiple occurrences of a string within a list?
Subscriber123
subscriber123 at gmail.com
Thu Apr 5 14:24:23 EDT 2007
for item in listA:
while item in listB:
listB.remove(item)
where listA is the list of things you want to remove from listB
On 3 Apr 2007 11:20:33 -0700, bahoo <b83503104 at yahoo.com> wrote:
>
> Hi,
>
> I have a list like ['0024', 'haha', '0024']
> and as output I want ['haha']
>
> If I
> myList.remove('0024')
>
> then only the first instance of '0024' is removed.
>
> It seems like regular expressions is the rescue, but I couldn't find
> the right tool.
>
> Thanks!
> bahoo
>
> --
> http://mail.python.org/mailman/listinfo/python-list
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20070405/a26fa189/attachment.html>
More information about the Python-list
mailing list