if statement multiple or

Christian Heimes lists at cheimes.de
Fri May 6 08:25:27 EDT 2011


Am 06.05.2011 14:09, schrieb scattered:
> sets could also work
> 
> if set('abc') & set(line) == set():
>      print line

Right!
Sets work in this special case, because the OP just wants to search for
a single char. It won't work for longer strings, though.

Also I would write the test as:

if set(line).isdisjoint("abc"):
    print line

Christian





More information about the Python-list mailing list