vendredi 25 janvier 2019

using random in python's list and print it but the output is empty

here my code

import random
def check_for_greeting(sentence):
    for word in sentence :
        if word in GREETING_KEYWORDS:
            print (random.choice(GREETING_RESPONSES))

print("start talking : ")
sentence=input().strip()
GREETING_KEYWORDS = ["hello", "hi", "greetings", "sup", "what's up"]
GREETING_RESPONSES = ["'sup bro", "hey", "hey you get my snap?"]
while True :
    check_for_greeting(sentence)
    sentence=input().strip()
    if sentence =="end" : break

like a chatbot. I want it to reply 1 word from random GREETING_RESPONSES if There is keyword ps. I'm a beginner for coding. correct me if my code has something wrong




Aucun commentaire:

Enregistrer un commentaire