Command Palette

Search for a command to run...

Hectal
Phase 3: Prompting as Engineering
LLM Engineering · Exercise 3 of 6 PreviousNext
Intermediate

A strict single-pass template filler

Write render(template, values) that replaces every {{name}} in template with values["name"] in one pass (the text you insert must never be scanned again).

If a blank has no value, raise ValueError("missing variable: <name>"). Use the re module; the pattern for a blank is \{\{(\w+)\}\}.

What Check tests

  1. Fills every blank
  2. A repeated blank is filled each time
  3. A missing value raises ValueError with the name
  4. A value that looks like a blank is NOT expanded
  5. Text without blanks is unchanged

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.