Untitled
unknown
plain_text
a year ago
1.1 kB
17
Indexable
def get_response(user_input):
# Defining some basic responses using a dictionary
responses = {
"hi": "Hello!",
"hey": "Hello! How can I help you?",
"how are you": "I'm just a bot, I'm doing well. How about you?",
"bye": "Goodbye! Have a great day!",
"what's your name": "I'm a chatbot. You can call me by any name.",
"what can you do": "I can help you with a variety of things. Try asking me about the weather!",
"how is the weather": "I'm not sure. You should check your weather app!"
}
# Normalizing user input so that it's case-insensitive
user_input = user_input.lower().strip()
# Getting response based on user input
return responses.get(user_input, "Sorry, I didn't understand that.")
def chat():
print("Welcome to the chatbot! Type 'bye' to end the chat.\n")
while True:
user_input = input("You: ")
response = get_response(user_input)
print("Chatbot:", response)
if user_input.lower() == "bye":
break
if __name__ == "__main__":
chat()Editor is loading...
Leave a Comment