Intermediate
Check an answer's citations
Write cited_ids(answer) returning every id written in square brackets, in order ("See [D8] and [D6]." gives ["D8", "D6"]). Ignore an unclosed [.
Write review(answer, retrieved) returning "ok" when answer equals REFUSAL; otherwise "no evidence" when retrieved is empty, "no citation" when nothing is cited, "unknown source" when any cited id is not in retrieved, else "ok". Check in that order.
What Check tests
cited_idsfinds ids in order- An unclosed bracket is ignored
- A made-up citation is caught
- An answer without a citation is caught
- Answering with nothing retrieved is caught; refusing is fine
- A correct answer passes
Stuck? One hint at a time
The solution unlocks after your first Check. Try first: that is where the learning happens.
main.py
Sign in to run your code.
Output
Press Run to see what your program prints.