I’m trying to check if a list has no member as boolean operator AND, OR, NOT.
while ('AND' and 'OR' and 'NOT') not in list: print 'No boolean operator'
However, when my input is:
a1 c2 OR c3 AND, it prints ‘No boolean operator’, which means this list is considered no boolean operator in it by using above loop sentence.
Hope somebody can help to correct.
sets will be screaming fast if you have any volume of data
If you are willing to use sets, you have the
isdisjoint() method which will check to see if the intersection between your operator list and your other list is empty.
MyOper = set(['AND', 'OR', 'NOT']) MyList = set(['c1', 'c2', 'NOT', 'c3']) while not MyList.isdisjoint(MyOper): print "No boolean Operator"