Return 'true’ only if it satisfies 2 conditions

Now I am trying an opposite case…

I want the test to return "true’ only if it satisfies 2 conditions:

  1. it contains ‘010’
  2. it doesn’t contain ‘100’ and ‘001’

image

Reversing the script, I wasn’t able to achieve the desired result. Index 6 (which contains ‘100’ and ‘001’) should return “false”.

Any help is appreciated. Thanks.
Zirjay

@zilong245

OUT=[]
for lst in IN[0]:
if not all (item in lst for item in IN[1]) and IN[2] in lst:
OUT.append(True)
else:
OUT.append(False)

Please start a new topic for any other questions and mark a solution for this one

4 Likes

Thanks @Vikram_Subbaiah ! This worked for me!

2 Likes