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
- Fills every blank
- A repeated blank is filled each time
- A missing value raises ValueError with the name
- A value that looks like a blank is NOT expanded
- 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.