Goal: Build a simple chatbot that responds to predefined user inputs using pure control flow logic.
Key Concepts: Control flow, decision-making logic, dictionary-based lookup, input sanitization.
How it works:
- Takes raw user input and normalizes it with
.lower().strip() - Looks up the cleaned input against a dictionary of known intents using
.get()with a fallback response - Runs in a continuous
while Trueloop and exits cleanly on a kill command
Files: chatbot.py
How to run:
cd "C:\Users\user\OneDrive\Desktop\Project1"
python chatbot.py
Sample interaction:
Chatbot: Hello! I'm your rule-based assistant. Type 'bye' to exit.
You: hello
Chatbot: Hi there! How can I help you today?
You: bye
Chatbot: Goodbye! Have a great day.