A small example. I have two lists with numbers, ra
and dec
here. I have a third list that also has some numbers, quad
here.
What I want to do is to remove those values of ra
and dec
that are in quad
.
>>> ra = [1,1,1,2,3,4,5,6,7,8]
>>> dec = [1,2,3,4,5,6,7,7,7,7]
>>> quad = [1,2,3,1,2,3]
>>> new_ra = []
>>> new_dec = []
>>> for a,b in zip(ra,dec):
if ((a not in quad) & (b not in quad)):
new_ra.append(a)
new_dec.append(b)
So here you would expect:
new_ra = [4,5,6,7,8]
and
new_dec = [4,5,6,7,7,7]
How ever, I get:
new_ra = [4,5,6,7,8]
as expected, BUT,
new_dec = [6,7,7,7,7]
Why is this so? What is wrong with my loop?
P.S. I am following the same method as in THIS QUESTION, but my second list does not give me the proper answer.