Dealing with multiple sets
John Henry
john106henry at hotmail.com
Wed Oct 25 20:18:33 EDT 2006
Aye!
I did a:
a and b and c
Bonk!
Thanks,
Tim Peters wrote:
> [John Henry]
> > If I have a bunch of sets:
> >
> > a = set((1, 2, 3))
> > b = set((2, 3))
> > c = set((1, 3))
> > ....
> >
> > What's the cleanest way to say:
> >
> > 1) Give me a list of the items that are in all of the sets? (3 in the
> > above example)
>
> list(a & b & c)
>
> > 2) Give me a list of the items that are not in all of the sets? (1,2 in
> > the above example)
>
> list((a | b | c) - (a & b & c))
More information about the Python-list
mailing list