Parse CSV without splitting on commas
CSV fields can contain commas, quotes and line breaks. Splitting text manually loses that structure. DictReader understands the format and names fields using the header. Normalize only fields whose rules you know: an email is trimmed and lowercased here, while the supplied display name keeps its internal spaces.
import csv, io
text = "name,email\nAda,a@x.test"
rows = csv.DictReader(io.StringIO(text))
print(next(rows)["name"])Think before coding
The parser handles escaping before normalization begins. Treating parsing and field cleanup as separate steps preserves names containing commas while giving predictable email keys. Work through the example by hand before changing the starter. Decide what should happen for an empty input, a single value and a repeated value where those cases apply. The checks use several inputs so a hard-coded answer cannot stand in for the rule.
Your task
Write contacts(text). Parse CSV columns name,email; return (trimmed_name, trimmed_lowercase_email) tuples for rows with both values nonempty. Preserve row order and correctly parse quoted commas.
The explanation opens here once every check passes.