You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
ML-For-Beginners/6-NLP/1-Introduction-to-NLP/solution/bot.py

27 lines
997 B

import random
# This list contains the random responses (you can add your own or translate them into your own language too)
random_responses = ["That is quite interesting, please tell me more.",
"I see. Do go on.",
"Why do you say that?",
"Funny weather we've been having, isn't it?",
"Let's change the subject.",
"Did you catch the game last night?"]
print("Hello, I am Marvin, the simple robot.")
print("You can end this conversation at any time by typing 'bye'")
print("After typing each answer, press 'enter'")
print("How are you today?")
while True:
# wait for the user to enter some text
user_input = input("> ")
if user_input.lower() == "bye":
# if they typed in 'bye' (or even BYE, ByE, byE etc.), break out of the loop
break
else:
response = random.choices(random_responses)[0]
print(response)
print("It was nice talking to you, goodbye!")