mercredi 19 avril 2017

Why my if statement is not working? (Python)

Why the if statement in the bottom of my code does not work? the words list contain several 'test', but the print statement below the if statement did not works.

text1 = "a"
text2 = "b"
text3 = "c"
words = []
if len(text1) < 2:
    words.append('test11')
elif text1.isspace():
    words.append('test12')
if len(text2) < 2:
    words.append('test21') 
elif text2.isspace():
    words.append('test22')
if len(text3) < 2:
    words.append('test31')
elif text3.isspace():
    words.append('test32')
if "test" in words:
    print "Test"

Aucun commentaire:

Enregistrer un commentaire