I'm attempting to check if a string element(s) are contained in a list.
Code :
if('a' in ['notin']):
print('test')
Does not print a value, which makes sense.
Code :
if('a' or 'b' or 'c' in ['notin']):
print('test')
prints test
. Why is 'test' printed as a
, b
or c
is not in notin
?
I'm not implementing this conditional correctly ?
This is not a duplicate question as solution based on reading comments I've written is unique :
if any (t in ['a' , 'b' , 'c'] for t in ['a' , 'b']) :
print('in list')
if not any (t in ['a' , 'b' , 'c'] for t in ['d' , 'e']) :
print('not in list')