January 22, 2026 - Using .casefold() for Case-Insensitive String Comparison in Python
When you need to compare string in Python, a lot of us reach for .strip().lower() by default to pre-normalize the strings. But it turns out that .lower() doesn’t really work when you start thinking about non-ASCII characters. For example, the German letter “ß” (Eszett) should probably be equivalent to “ss” in a case-insensitive comparison, but .lower() doesn’t handle that correctly. So how can we do better? Python has a method ....