Read first
Task 18
Fallback answers
Every assistant needs a fallback. When nothing matches, give the phone number instead of inventing an answer — a wrong fee is worse than "please call us".
Task
What should the fallback do?
The editor already contains a starting point. Change it until every check passes — the Next task button unlocks when it does.
What you start with
def answer(question, faq, fallback):
q = question.lower()
for key in faq:
if key in q:
return faq[key]
return fallback
faq = {'fee': 'Rs 11,667 per month for Python.', 'timing': 'Monday to Saturday, 10:00 to 20:00.'}
print(answer('What is the fee?', faq, 'Please call +92 325 8000848.'))
print(answer('Do you teach cooking?', faq, 'Please call +92 325 8000848.'))
Python
1 automatic check Prompt engineering
Code editor
Ctrl + Enter runs
Run your code to see the output and the checks.
Your result
Submit your code to see results
Write your code in the middle column and press Run code.
Next task (pass every check first)
Hint
Ask yourself: What should the fallback do?