So I wrote a short and simple chat bot in Python, however there's an irritating issue. The program will only call the posResponses()
function initially.
In context, if I respond to its initial question with 'sad', 'terrible' or even 'asdfasdfasdf' I will still get a positive response.
What should happen is if I input a negative/ambiguous keyword the negResponses()
/ambiguousResponses()
function should be called. That is not the case. What did I do wrong, and how do I fix it? Code is as follows:
import random
import time
def opening():
print('Hello!')
def responseType():
responseType = str(input('How are you ?'))
if responseType == 'good' or 'great' or 'fantastic' or 'decent' or 'fine' or 'ok' or 'okay': posResponses()
elif responseType == 'bad' or 'terrible' or 'sad' or 'grumpy' or 'angry' or 'irritated' or 'tired': negResponses()
else: ambiguousResponses()
def posResponses():
number = random.randint(1, 4)
if number == 1:
print('That\'s great! So what\'s up?')
input()
ambiguousResponses()
if number == 2:
print('Really? I\'d like to hear more.')
input()
ambiguousResponses()
if number == 3:
print('I\'m glad to hear that. What\'s going on?')
input()
ambiguousResponses()
if number == 4:
print('Ah, me too. You should begin a topic discussion.')
input()
ambiguousResponses()
def negResponses():
number2 = random.randint(5, 8)
if number2 == 5:
print('That\'s really too bad. Care to elaborate?')
input()
ambiguousResponses()
if number2 == 6:
print('Awww. Why?')
input()
ambiguousResponses()
if number2 == 7:
print('That sucks! How come?')
input()
ambiguousResponses()
if number2 == 8:
print('What a shame! You should explain why.')
input()
ambiguousResponses()
def ambiguousResponses():
number = random.randint(1, 4)
if number == 1:
print('Interesting. Carry on.')
input()
ambiguousResponses()
if number == 2:
print('Wow, elaborate!')
input()
ambiguousResponses()
if number == 3:
print('What an astute remark! Continue.')
input()
ambiguousResponses()
if number == 4:
print('How interesting. Please do explain further.')
input()
ambiguousResponses()
if __name__ == "__main__":
opening()
responseType()