LLM Engineering · Exercise 6 of 6 Previous
Intermediate
Parse the final answer line
A model writes its steps and then a last line Answer: <integer>. Write final_answer(reply) that returns that integer, using the last line that starts with Answer:.
If there is no such line, or the text after Answer: is not an integer, return None.
What Check tests
- Reads the answer line
- Ignores numbers in the steps
- No answer line gives None
- A non-integer answer gives None
- The last Answer line wins
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.