jeudi 13 février 2020

Extracting first word from user input

To start, I am a complete beginner and am working on a "fortune teller" type program (kind of like magic 8 ball)for my intro to compsci class. I have it working where any input will use (answers[random.randint(0,len(answers)-1)]) to choose from a pre-generated list of "answers" and it works great. I got to thinking what if I could make multiple lists that would be triggered by the first word of the user's input? So if it begins with "Why" than a list that would answer a why question (ambiguously of course) would be randomly picked from. Questions that begin with "Who" would choose from a different list and so on. I have tried different ideas that I found on the internet but can't seem to get them to work right. I would appreciate any hints or helping hands that I can get.




Aucun commentaire:

Enregistrer un commentaire