transformation

str.title

Returns a titlecased copy where the first letter of each word is uppercase and the rest are lowercase. Word boundaries are defined by any run of non-letter characters, including apostrophes.

str.title()

Parameters

Parameter Purpose
self operates on the calling string; takes no arguments
returns new titlecased str (original unchanged — str is immutable)

Examples

>>> 'hello world'.title()
'Hello World'

each word gets capitalized

>>> "they're here".title()
"They'Re Here"

apostrophe splits the word (a common gotcha)

>>> 'HELLO WORLD'.title()
'Hello World'

existing uppercase is normalized

>>> '2nd place'.title()
'2Nd Place'

digits count as non-letters so the next letter capitalizes

Gotcha

The apostrophe rule ('they're' -> 'They'Re') often surprises. For proper English titles use string.capwords() or a library like `titlecase`.

Related methods

← All Python string methods · Python built-ins