LLM Engineering · Exercise 1 of 5Next
Intermediate
Redact, then log
Write redact(text) that replaces every email (letters, digits, dots, dashes and underscores, then @, a domain with a dot) with [EMAIL] and every run of exactly 10 digits (not part of a longer number) with [PHONE].
Write log_line(event, fields) that returns one line of compact JSON (separators=(",", ":")) with "event" first and then the fields in the order given. If the fields contain a "prompt" key, its value must be redacted before it is written.
What Check tests
redacthides an emailredacthides a 10-digit phone number- A 12-digit number is not a phone number
log_linewrites compact JSON with the event firstlog_lineredacts the prompt before writing
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.