list_a-list_b

Michael Gilfix mgilfix at eecs.tufts.edu
Wed Apr 17 00:13:22 EDT 2002


  Here's a one line example that doesn't touch either of the lists
that you might like and I think it pretty clear.

  new_list = filter (lambda x, list=list_b: x not in b, list_a)

                 -- Mike

On Tue, Apr 16 @ 19:30, John wrote:
> 
> Hi, I need a help in writing a function that does
> 
> list_a=[1,2,4], list_b=[2,4]
> list_minus(list_a,list_b)
> print list_a #will print out a=[1] after removing all elements ([2,4])
> appearing in list_b

-- 
Michael Gilfix
mgilfix at eecs.tufts.edu

For my gpg public key:
http://www.eecs.tufts.edu/~mgilfix/contact.html
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 236 bytes
Desc: not available
URL: <http://mail.python.org/pipermail/python-list/attachments/20020417/bc6fb53d/attachment.sig>


More information about the Python-list mailing list