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
- One address is replaced
- Every address is replaced
- Text without an address is unchanged
- 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.