Test if list contains another list
James Mills
prologic at shortcircuit.net.au
Mon Sep 8 05:29:21 EDT 2008
Hi,
>>> a = [1,2,3]
>>> b = [3,2,1,4]
>>> a = set(a)
>>> b = set(b)
>>> a.intersection(b)
set([1, 2, 3])
Is this what you want ?
cheers
James
On 9/8/08, mathieu <mathieu.malaterre at gmail.com> wrote:
> Hi there,
>
> I am trying to write something very simple to test if a list
> contains another one:
>
> a = [1,2,3]
>
> b = [3,2,1,4]
>
> but 'a in b' returns False. How do I check that a is indeed contained
> in b ?
>
> thanks
>
> --
> http://mail.python.org/mailman/listinfo/python-list
>
--
--
-- "Problems are solved by method"
More information about the Python-list
mailing list