-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBasic Chatbot
More file actions
22 lines (20 loc) · 751 Bytes
/
Copy pathBasic Chatbot
File metadata and controls
22 lines (20 loc) · 751 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
def get_response(user_input):
# Convert input to lowercase for case-insensitive matching
user_input = user_input.lower().strip()
# Predefined responses
if user_input in ["hello", "hi", "hey"]:
return "Hi!"
elif user_input in ["how are you", "how are u", "how's it going"]:
return "I'm fine, thanks!"
elif user_input in ["bye", "goodbye", "see you"]:
return "Goodbye!"
else:
return "Sorry, I don't understand. Try saying 'hello', 'how are you', or 'bye'."
# Main chatbot loop
print("Welcome to the Chatbot! Type 'bye' to exit.")
while True:
user_input = input("You: ")
response = get_response(user_input)
print("Bot:", response)
if response == "Goodbye!":
break