Chatbot
while True:
msg = input()
if "hi" in msg:
print("hello!")
elif "bye" in msg:
print("nice chat - bye!")
break
else
print("ok")
This is the skeleton of a chatbot program:
- An endless loop.
- Read a message from the user with the
input()function and assign it to themsgvariable. - If "hi" is part of the message, respond with "hello!".
- If "bye" is part of the message, respond with "nice chat - bye!" and break out of the endless loop with the
breakkeyword. - Otherwise, respond with "ok".