Command Palette

Search for a command to run...

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

  1. Only a task gives one line
  2. All four parts appear in the right order
  3. Empty parts are skipped
  4. 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.