String Methods

str.casefold()

Produce text suitable for Unicode default caseless comparisons. Unlike lower(), this can expand characters and collapse distinctions such as Greek final sigma. Casefolding does not itself normalize canonically equivalent spellings, implement locale-specific collation, or detect confusable identifiers. Keep the original display spelling. The receiver is immutable; the operation returns a string without modifying it. Do not rely on a new object identity.

Formal Syntax & Structure

python syntaxpython
text.casefold()

Return Value

str

String containing the transformed text.

Working Example

Example Snippetpython
names = ["Straße", "STRASSE"]print(names[0].lower() == names[1].lower())print(names[0].casefold() == names[1].casefold())print("سلام".casefold())
Python Reference