Error in or

Marko Rauhamaa marko at pacujo.net
Fri Jun 12 05:55:08 EDT 2015


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



More information about the Python-list mailing list