Steven D'Aprano <steve+comp.lang.python at pearwood.info>: > This is better written as: > > if any(substr in inp1 for substr in > ['AND', 'OR', 'NOT', '>', '&', 'MAYBE', '(', '*', ' " ']): > print 'FINE' Or, equivalently: for substr in ['AND', 'OR', 'NOT', '>', '&', 'MAYBE', '(', '*', ' " ']: if substr in inp1: print('FINE') break Marko