EchoBot II
Having written your respond() function, you'll now define a function called send_message() with a single parameter message which logs the message and the bot's response.
This exercise is part of the course
Building Chatbots in Python
Exercise instructions
- Use the
user_templatestring's.format()method to include the user'smessageinto the user template, and print the result. - Call the
respond()function with the message passed in and save the result asresponse. - Log the bot's
responseusing thebot_templatestring's.format()method. - Send the message
"hello"to the bot.
Hands-on interactive exercise
Have a go at this exercise by completing this sample code.
# Create templates
bot_template = "BOT : {0}"
user_template = "USER : {0}"
# Define a function that sends a message to the bot: send_message
def ____(____):
# Print user_template including the user_message
print(____.format(____))
# Get the bot's response to the message
response = ____(____)
# Print the bot template including the bot's response.
print(____.format(____))
# Send a message to the bot
send_message("____")