The following script is returning false, when I think that it should be returning true. Any idea what is going on here? Thanks so much, guys!
test=['Pop']
test1='Pop'
if (test==('POP' or 'Pop' or 'pop' or ['POP'] or ['Pop'] or ['pop'])):
print "yes"
else:
print "no"
Currently, the output is, ‘no’.
You aren’t understanding how python processes the statement. Python isn’t natural language.
Because the
oris inside the parens, it processes it first. So it looks atSince [‘Pop’] is considered True, python reduces the whole statement to:
At this point, it tests whether
testis equal to['Pop']What you are actually wanting to do is:
This is completely different than