dimanche 2 août 2015

Python - If statement check list contains is returning true when it shouldn't

I have a list which contains the values:

['1', '3', '4', '4']

I have an if statement which will check if the values are contained within the list then output a statement:

if "1" and "2" and "3" in columns:
    print "1, 2 and 3"

Considering the list doesn't contain value "2", it should not print the statement, however it is:

Output:

1, 2 and 3

Can someone explain why this is the case? Is it the way Python reads the list that is making this occur?

Aucun commentaire:

Enregistrer un commentaire