Hint
🧠Not sure where to start?
Start by creating an infinite loop that keeps asking the user for input:
while True:
user_input = input("You: ").lower()
Now think: how can you respond to specific messages like "hello"
or "bye"
? You can use an if
statement like:
if user_input == "hello":
print("ChatBot: Hello there!")
Add more elif
statements for other known phrases, and use an else
block for unknown input:
else:
print("ChatBot: Sorry, I don't understand that.")
To exit the loop when the user says "bye"
, just add:
if user_input == "bye":
print("ChatBot: Goodbye!")
break