Python - if x not in any of a, b, c

if-statement, python

Solution

You can do that as:

if all(x not in i for i in (a,b,c)):

The `all` above will only evaluate to `True` if x is not in any of a,b, or c

Or in other words:

if not any(x in i for i in (a,b,c)):

Problem

In a program I am writing at the moment I need to do the following: ``` if (x not in a) and (x not in b) and (x not in c): ``` which, of course, is very tedious, especially when a, b, and c all have much longer names. Is there a built-in function that can do this: ``` if x is_in_one_of(a, b, c): ``` I know how I can do this with a function, and I am just wondering if there is a built-in way to do it. Thanks in advance

Original source