Command Palette

Search for a command to run...

Hectal
Phase 2: Calling a Model
LLM Engineering · Exercise 5 of 6 PreviousNext
Beginner

Redact API keys from log lines

Keys look like sk- followed by 8 or more letters or digits. Write mask(key) returning the first 3 characters, ... and the last 4 characters, and redact(text) that replaces every key in text with its masked form.

Text without a key must come back unchanged, and sk- followed by fewer than 8 characters is not a key.

What Check tests

  1. mask keeps the first 3 and last 4 characters
  2. redact masks a key inside a sentence
  3. Two keys in one line are both masked
  4. Text without a key, or with a too-short one, 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.