Normalize emails under a declared policy · Python (pandas)
Task: the rules
Input contacts(id, email) — text. id is unique. Emails are ASCII and always present. Rules (this fictional system's declared policy) email: remove ASCII whitespace (space, tab, CR, LF) at both ends, then lowercase the whole address. Do not remove dots, plus tags or anything else; do not merge contacts. Running the rule twice changes nothing. Output (row order does not matter) clean(id text, email text)
Tab inserts spaces. Press Escape, then Tab, to move focus out of the editor.
| # | idstring | emailstring |
|---|---|---|
| 1 | c2e40 | ⇥s.am@Shop.Example.net· (raw value "\ts.am@Shop.Example.net ") |
| 2 | co4rf | ··carol_99@MAIL.example.org·· (raw value " carol_99@MAIL.example.org ") |
| 3 | cf5co | Sam+offers@example.COM |
| 4 | c3vyo | ··carol_99@Example.com·· (raw value " carol_99@Example.com ") |
| 5 | cgbcs | ⇥bob@example.com⇥ (raw value "\tbob@example.com\t") |
| 6 | cmnxs | ··Sam+offers@Shop.Example.net·· (raw value " Sam+offers@Shop.Example.net ") |
| 7 | crnsn | ·s.am@example.COM· (raw value " s.am@example.COM ") |
| 8 | c8m37 | ··sam+offers@mail.example.org·⇥ (raw value " sam+offers@mail.example.org \t") |
| 9 | c7og7 | ··s.am@MAIL.example.org·· (raw value " s.am@MAIL.example.org ") |
| 10 | cghwl | ·⇥carol_99@MAIL.example.org·⇥ (raw value " \tcarol_99@MAIL.example.org \t") |
| 11 | c80if | ·Ann.Lee@Example.com·· (raw value " Ann.Lee@Example.com ") |
| 12 | c942l | dan+news+2026@example.com |
Run preview · in your browser, not a grade
Loading the preview runtime…
Check answer · graded on an isolated server, including hidden datasets
Your code runs in a locked-down machine with no network, on the visible data and on hidden datasets that follow the same rules.
Learn from this exercise
A worked solution becomes available after your first check or once you've used every hint.