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.
Este exercício faz parte do curso
Building Chatbots in Python
Instruções do exercício
- 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.
Exercício interativo prático
Experimente este exercício completando este código de exemplo.
# 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("____")