Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Chatbot
#1
import random
greetings = ['hola', 'hello', 'hi', 'Hi', 'hey!','hey']
question = ['How are you?','How are you doing?']
responses = ['Okay',"I'm fine"]
question1 = ['Install Type']
responses1 = ['AOInstall','Standalone Install']
while True:
        userInput = input(">>> ")
        if userInput in greetings:
                random_greeting = random.choice(greetings)
                print(random_greeting)
        elif userInput in question:
                random_response = random.choice(responses)
                print(random_response)     
        elif userInput in question1:
                random_response = random.choice(responses1)
        else:
                print("I did not understand what you said")
>>> hi
hey!
>>> How are you?
Okay
>>> Install Type --- > this does not give a response
>>>
I did not understand what you said
>>> Install Type
>>>
Reply
#2
Executed in my Pycharm and received the output without any hassle
import random
greetings = ['hola', 'hello', 'hi', 'Hi', 'hey!','hey']
question = ['How are you?','How are you doing?']
responses = ['Okay',"I'm fine"]
question1 = ['Install Type']
responses1 = ['AOInstall','Standalone Install']
while True:
        userInput = input(">>> ")
        if userInput in greetings:
                random_greeting = random.choice(greetings)
                print(random_greeting)
        elif userInput in question:
                random_response = random.choice(responses)
                print(random_response)
        elif userInput in question1:
                print("Received question1")
                random_response = random.choice(responses1)
                print(random_response)
        else:
                print("I did not understand what you said")


Output:
>>> Install Type Received question1 AOInstall
And I'm using Python3
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Chatbot AI mmagner2022 1 1,402 Jan-20-2022, 08:26 AM
Last Post: ibreeden
  Hi, I need some guidance with the dialogue for my chatbot aaron10500 0 1,333 Jun-22-2021, 02:38 PM
Last Post: aaron10500
  Chatbot with word2vec maik282 0 2,065 Apr-30-2019, 01:49 PM
Last Post: maik282

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020