ChitChat
_________________________________________________________________________________
Problem No 3)
Asking questions is a great way to create an engaging conversation. Here, you'll create the very first hint of ELIZA's famous personality, by responding to statements with a question and responding to questions with answers.
A dictionary of responses with "question" and "statement" as keys and lists of appropriate responses as values has already been defined for you. Explore this in the Shell with responses.keys() and responses["question"].
Problem Solution)
#import random module
import random
def respond(message):
# Check for a question mark
if message.endswith("?"):
# Return a random question
return random.choice(responses["question"])
# Return a random statement
return random.choice(responses["statement"])
# Send messages ending in a question mark
send_message("what's today's weather?")
send_message("what's today's weather?")
# Send messages which don't end with a question mark
send_message("I love building chatbots")
send_message("I love building chatbots")
_________________________________________________________________________________