Command Palette

Search for a command to run...

Hectal
Phase 3: Prompting as Engineering
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

  1. Reads the answer line
  2. Ignores numbers in the steps
  3. No answer line gives None
  4. A non-integer answer gives None
  5. 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.