Untitled
unknown
plain_text
a year ago
810 B
0
Indexable
Never
import random # Define some sample responses responses = { "hello": ["Hello!", "Hi there!", "Hey!"], "how are you": ["I'm good, thanks!", "I'm doing well.", "I'm a chatbot, so I don't have feelings."], "bye": ["Goodbye!", "See you later!", "Have a great day!"], "default": ["I'm not sure what you mean.", "Could you please rephrase that?", "I didn't understand."], } def get_response(user_input): user_input = user_input.lower() response = responses.get(user_input, responses["default"]) return random.choice(response) # Main loop print("Chatbot: Hello! Type 'bye' to exit.") while True: user_input = input("You: ") if user_input.lower() == "bye": print("Chatbot: Goodbye!") break response = get_response(user_input) print(f"Chatbot: {response}")