2016-04-08 4 views
1

Je suis nouveau sur Python et quand vous exécutez ce code, peu importe ce que vous répondez à "Comment va votre journée?" Il répond avec "C'est bon". Qu'est-ce que je fais mal?Erreur dans Chatbot simple

import random 

yes = ['yes', 'Yes', 'Yeah', 'yeah', 'Yea', 'yea', 'Mhmm', 'mhmm', 'Mhm', 'mhm'] 
no = ['No', 'no', 'Nah', 'nah'] 
good = ['Good', 'good', 'Great', 'great', 'Okay', 'okay', 'Ok', 'ok', 'OK'] 
bad = ['Bad', 'bad', 'Not good', 'not good', 'Not well', 'not well'] 

random_yes = random.choice(yes) 
random_no = random.choice(no) 
random_good = random.choice(good) 
random_bad = random.choice(bad) 

greetings = ['Hola', 'Hello', 'Hi', 'Hey!','hey...'] 
random_greeting = random.choice(greetings) 

print(random_greeting) 

name = input('What is your name?') 
print('Hello', name,) 

question1 = ['How are you?','How are you doing?','How is your day?','How is your day going?'] 
random_question1 = random.choice(question1) 

ur1 = input(random_question1) 

if good in ur1: 
    print("That's good") 
elif bad in ur1: 
    print("I'm sorry") 
else: 
    print("I don\'t understand") 

Répondre

0

votre si les conditions sont d'autre mal, vous êtes à la recherche d'une liste good dans la chaîne ur1

Code

devrait être

if ur1 in good: 
    print("That's good") 
elif ur1 in bad: 
    print("I'm sorry") 
else: 
    print("I don\'t understand")