CKTIS / Python
str.title
Capitalizes word starts and lowercases the remaining cased characters.
Version: Python 3.14; repository image, production runtime not attested
Syntax
s.title()Capitalizes word starts and lowercases the remaining cased characters.
An apostrophe is treated as a word boundary, which can give unexpected capitalization inside contractions.
The algorithm uses runs of cased characters: words start in titlecase and later cased letters are lowercased. The apostrophe interrupts a run, so the r in the contraction is capitalized too. This behavior is not language-specific editorial title casing.
assert "they're".title() == "They'Re"
Examples
print("new YORK".title())
print("they're".title())
Result
New York They'Re
The algorithm uses runs of cased characters: words start in titlecase and later cased letters are lowercased. The apostrophe interrupts a run, so the r in the contraction is capitalized too. This behavior is not language-specific editorial title casing.