Hello everyone! there is a construction like:
if a in b:
print (a)
elif a in c:
print (a)
elif a in d:
print (a)
else:
pass
how to make the variable a print only when ALL if-conditions are fulfilled, and if at least one of them is not fulfilled, then pass? only crutches come to mind, but I wanted a laconic solution
Answer 1, authority 100%
If all conditions must be met:
if (a in b and a in c and a in d):
print (a)
else:
pass
If at least one condition must be met:
if (a in b or a in c or a in d):
print (a)
else:
pass
Answer 2, authority 98%
To check if an element is contained in all available collections:
if all (item in it for it in collections):
print (item)
where for example: collections = b, c, d
.
To check if an element is contained in any from the collections:
if any (item in it for it in collections):
print (item)