Python Function Reference

str.title

Make the first letter of each word uppercase and the rest lowercase.

Python 3.13
str.title()

Return value

A new string; the original is not changed.

Examples

Capitalizing each word

Python 3.13
print('hello world'.title())
Hello World

Uppercase letter after an apostrophe

Python 3.13
print("they're here".title())
They'Re Here

Details

Any run of letters counts as a word, so a letter after an apostrophe also becomes uppercase: "they're" turns into "They'Re".

See also

Where to learn