nested looping

PK superprad at
Wed Apr 8 23:15:58 CEST 2009

So I'm trying to see whats the cleanest way to do this:

I have a

checklist = [ax, bx, by, cy  ..] (a combination of a,b,c with x and y,
either both on one)

allist = [a,b,c,....]
xlist = [x, y, ..]

now I wanna loop through alist and xlist and see if the combination
exists in checklist

so something like,

for alpha in alist:
    for xy in xlist:
        if alpha+xy not in checklist:

now the problem is I want to include alpha in missing list only if
none of the combinations from xlist with alpha are in checklist.

The above will exclude the possibility where ax doesn't exist but ay
or az does exist.

Hope There is a cleaner way to accomplish this.

Thanks in advance,

More information about the Python-list mailing list