all Python 3Strings (str)function
str.title
case
Return a titlecased version: each word starts with an uppercase letter.
Syntax
s.title()
title() treats any character following a non-letter as a word start, so apostrophes break it (don't becomes Don'T) and inner capitals are lost: McDonald turns into Mcdonald. string.capwords() splits on whitespace only and so handles apostrophes, but it lowercases inner capitals just the same; real-world headings need your own word-by-word logic; title() only suits plain text without apostrophes or compound names.
Examples
print('hello world'.title()) # → Hello World
print('пример строки'.title()) # → Пример Строки
print("don't stop".title()) # → Don'T Stop
See also
Open in the full glossarydocs.python.orgReport an inaccuracy