jeudi 18 février 2021

bot not returning speech

I'm trying to have an 'if statement' change the response "barnaby" (name of the bot program) gives when the user says hello, hey, hi, hayo or yo, the bot will respond with 'whats up'. But when I tested it it didn't respond, instead, it didn't say anything, and rather just let the user keep typing. I've included some code:

you = 'yes'

inpt = 'jifo3'

def run():

  inpt = 'jifo3'

  you = 'yes'
  
  if inpt == 'jifo3':
    
    print("Hello there. I'm barnaby, the sub-par chatbot.")

  while True:
    
    if you == 'yes':
      
      inpt = input()
      
      you = 'no'
      
    if you == 'no':
          
      respond()
          
      you = 'yes'

def respond():
  
  if inpt == 'hi' or inpt == 'hello' or inpt == 'hey' or inpt == 'hayo' or inpt == 'yo':
    
    print('whats up?')
      
  else:
    
    print('I dont understand. Please try something more simple like "Hi" or "Hello"')

run()

Aucun commentaire:

Enregistrer un commentaire