Command Palette

Search for a command to run...

Hectal
Phase 10: Safety and Security (Defensive)
LLM Engineering · Exercise 2 of 5 PreviousNext
Intermediate

Redact email addresses

Write redact_emails(text) that replaces every email address in text with [EMAIL] and returns the new text. An address is letters, digits or . _ % + - before an @, then a domain of letters, digits, dots or dashes, a dot and at least two letters.

Use the re module. Text with no address must come back unchanged.

What Check tests

  1. One address is replaced
  2. Every address is replaced
  3. Text without an address is unchanged
  4. The empty string works

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.