| import random | |
| responses = { | |
| "hello": ["Hi there!", "Hello!", "Hey! How can I help you today?"], | |
| "how are you": ["I'm just a bot, but I'm doing great!", "I'm doing well, thank you!"], | |
| "bye": ["Goodbye!", "See you later!", "Take care!"] | |
| } | |
| def chatbot(): | |
| print("Chatbot: Hello! Type 'bye' to end the conversation.") | |
| while True: | |
| user_input = input("You: ").lower() | |
| if user_input == "bye": | |
| print("Chatbot: Goodbye!") | |
| break | |
| elif user_input in responses: | |
| print(f"Chatbot: {random.choice(responses[user_input])}") | |
| else: | |
| print("Chatbot: Sorry, I didn't understand that.") | |
| chatbot() | |