-1

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")
Eugene Yarmash
  • 142,882
  • 41
  • 325
  • 378
Luk
  • 185
  • 1
  • 2
  • 10

1 Answers1

2

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
Eugene Yarmash
  • 142,882
  • 41
  • 325
  • 378