LLM Engineering · Exercise 1 of 6Next
Beginner
Build a prompt from named parts
Write build_prompt(task, context="", audience="", fmt="") that returns the prompt as lines joined by a newline: Task: ... first, then Context: ..., Audience: ... and Format: ... in that order.
A part that is an empty string is skipped completely (no empty line).
What Check tests
- Only a task gives one line
- All four parts appear in the right order
- Empty parts are skipped
- The task line is first even if the other parts are given
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.