-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
  • 131,677
  • 37
  • 301
  • 358
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
  • 131,677
  • 37
  • 301
  • 358