ComenzarEmpieza gratis

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 ejercicio forma parte del curso

Building Chatbots in Python

Ver curso

Instrucciones del ejercicio

  • Use the user_template string's .format() method to include the user's message into the user template, and print the result.
  • Call the respond() function with the message passed in and save the result as response.
  • Log the bot's response using the bot_template string's .format() method.
  • Send the message "hello" to the bot.

Ejercicio interactivo práctico

Prueba este ejercicio completando el código de muestra.

# 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("____")
Editar y ejecutar código