For that use in
:
if a in (b, c):
Testing for membership in a tuple
has an average case of O(n)
time complexity. If you have a large collection of values and are performing many membership tests on the same collection of values, it may be worth creating a set
for speed:
x = set((b,c,d,e,f,g,h,i,j,k,l,...))
if a in x:
...
if y in x:
...
Once it has been constructed, testing for membership in the set
has an average case of O(1)
time complexity, so it is potentially faster in the long run.
Or, you can also do:
if any(a == i for i in (b,c)):