-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathecho_bot.py
More file actions
23 lines (18 loc) · 744 Bytes
/
Copy pathecho_bot.py
File metadata and controls
23 lines (18 loc) · 744 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#Program to write the echo bot
bot_template = "BOT : {0}"
user_template = "USER : {0}"
# Define a function that responds to a user's message: respond
def respond(message):
# Concatenate the user's message to the end of a standard bot respone
bot_message = "I can hear you! You said: " + message
# Return the result
return bot_message
# Define a function that sends a message to the bot: send_message
def send_message(message):
# Print user_template including the user_message
print(user_template.format(message))
# Get the bot's response to the message
response = respond(message)
# Print the bot template including the bot's response.
print(bot_template.format(response))
send_message("Hi, hello")