Prompt by example to tidy typed names
Your task
Your signup form saves names exactly as typed, so the database holds jOHN smith, MARY-JANE WATSON and o'brien. Support wants them tidied for emails and badges. An assistant will write clean_name(raw) in Python.
You could describe the rules in a paragraph. There are a lot of small cases, though, and a paragraph leaves room to guess.
Write the prompt you would give the assistant.
What you know:
- the cleaned name is for display only, and the raw value stays in the database
- many people type their names with care, such as
McDonald,DeShawnandPieter van der Berg - Python 3.12, no new dependencies
Then, in a few sentences: why do examples work better than rules here?