How to make this code work?
I want to check if some substrings are in list and some are not.
if 'A_' and 'V' and '3' and not 'ES' and not 'SF' in my_list[0:3]:
print("It's True")
How to make this code work?
I want to check if some substrings are in list and some are not.
if 'A_' and 'V' and '3' and not 'ES' and not 'SF' in my_list[0:3]:
print("It's True")
You could use the all()
function:
if all(x in L for x in wanted) and all(x not in L for x in not_wanted):
# do stuff