Question: Lets create a new chatbot. Let the chatbot has three lists. yeses = [yes, y, of course, certainly yes, sure] noses = [no, n, no

Lets create a new chatbot.

Let the chatbot has three lists.

yeses = ["yes", "y", "of course", "certainly yes", "sure"]

noses = ["no", "n", "no way", "of course not", "never"]

byes = ["Goodbye!", "See you!", "ciao", "Have a good day"]

Then check if the users response is one of these lists.

After the user gives a reasonable response

Offer the user to ask 2 yes/no questions.

For each such question, randomly choose whether the bot answers yes or no, and then use some of the yes/no variations.

Say goodbye in different ways.

Requirement: Must use a loop to check if user response is valid

Below is the pseudocode:

# import the random module

# create lists for yes answers, no answers and goodbyes

# ask the user if she wants to talk

# check whether the user provides a valid answer

# give the instruction for the user to provide a valid answer

# get the user's answer again

# show different responses based on the user's answer

# ask the user to ask a question and randomly provide a response from the yeses and noses lists

# ask the user to ask another question and randomly provide a response from the yeses and noses lists

# end the conversation and randomly provide a goodbye message from the byes list

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!