if statement multiple or

scattered tooscattered at gmail.com
Fri May 6 08:09:49 EDT 2011


On May 6, 7:00 am, Christian Heimes <li... at cheimes.de> wrote:
> Am 06.05.2011 12:47, schrieb Lutfi Oduncuoglu:
>
> > Hi,
>
> > I am trying to write a script and I realised that I need to use something
> > like
>
> > if ('a' or 'b' or 'c')  not in line:
> >    print line
>
> > But it does not work for. What may be the problem
>
> if any(s not in line for s in ('a', 'b', 'c')):
>    # do something
>
> Christian

sets could also work

if set('abc') & set(line) == set():
     print line



More information about the Python-list mailing list