How to compare strings correctly considering case/locale?
Answer
•For simple: s.lower() or s.casefold().
•casefold is better for Unicode.
•Locale-specific processing requires separate handling (locale).
•Don’t forget strip() for input.
•Use in/startswith/endswith for searching.
Was this answer helpful?