nested "and/or" if statements

Viewed 7054

I am working on code which creates a list and then applies both the "or" and "and" conditions to do further action:

a= ["john", "carlos", "22", "70"]

if (("qjohn" or "carlos") in a) and (("272" or "70") in a):
    print "true"
else:
    print "not true"

output:

not true

when I do this:

a= ["john", "carlos", "22", "70"]

if ("qjohn" or "cdarlos" in a) and ("272" or "d70" in a):
    print "true"
else:
    print "not true"

output is "true"

What I am not getting is **carlos and 70** should be equal to true but it's printing "not true". What is the cause of this error? Thanks

3 Answers
Related