mardi 21 juin 2016

If statement not recognizing word in list after using split()

I am trying to make a text parsing function, however, it is unable to recognize the first word.

I am using str.split() to locate the first word. I have tried putting multiple words and using other words but I keep getting the default I don't understand that word.

My code is here.

helptext = "How to use the parser"

def parse(text):
    words = text.split()
    if(words[0].lower == "help"):
        print(helptext)
    else:
        print("I don't understand that verb.")

parse("help")

To be clear, I want parse("help") to output the helptext variable into the Interpereter.

Aucun commentaire:

Enregistrer un commentaire