prize18-5 Exercise 3: Stripping Accents ======================================== Idea: NFD splits each accented letter into a base letter plus combining marks; marks have a non-zero combining class, so filtering on that removes them; NFC then recomposes whatever remains. Letters that have no decomposition (they are separate base letters, not letter-plus-mark) are untouched. ex3.py: import unicodedata as ud def strip_accents(s): d = ud.normalize("NFD", s) return ud.normalize("NFC", "".join(c for c in d if not ud.combining(c))) for word in ["Zo\u00eb", "cr\u00e8me br\u00fbl\u00e9e", "\u00c5ngstr\u00f6m", "\u00f8re", "stra\u00dfe", "\u0141\u00f3d\u017a"]: print(f"{word} -> {strip_accents(word)}") Real output (Python 3.14): Zoë -> Zoe crème brûlée -> creme brulee Ångström -> Angstrom øre -> øre straße -> straße Łódź -> Łodz Unchanged: the slashed o, the sharp s and the barred L. Each is its own base letter with no canonical decomposition into letter plus mark, so removing marks cannot touch them. Turning them into "o", "ss" or "L" needs a separate, language-specific table (an extra step, and a policy choice).