Command Palette

Search for a command to run...

Hectal
Phase 0: Start Here: What an LLM Is and Why Engineering Matters
LLM Engineering · Exercise 3 of 5 PreviousNext
Beginner

Check the model's total

A model writes order confirmations like "Your total is Rs 1,159.00.". Write claimed_total(reply) that returns the amount after "Rs " as a float (remove the thousands commas and a final full stop). Return None if the reply has no "Rs ".

Write total_ok(reply, items) where items is a list of (name, qty, price). Return True only if the claimed total is within 0.005 of the real total.

What Check tests

  1. claimed_total reads Rs 1,159.00. as 1159.0
  2. claimed_total returns None without Rs
  3. A correct total passes
  4. A wrong total fails
  5. A reply with no amount fails safely

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.