The title Method in Python: Capitalizing the First Letter of Words
The title method returns a copy of the string where each word starts with an uppercase letter and continues with lowercase. This style is typical for titles in English.
title()
'cat Whiskers!'.title() # Cat Whiskers!
"they're bill's friends from the UK".title()
# They'Re Bill'S Friends From The Uk
The method uses a simple, language-independent definition of a word — a group of consecutive letters. While this works in many cases, it can lead to unexpected results with words containing apostrophes, such as contractions and possessive forms (see the example above). In these cases, using regular expressions with the re module is recommended.
For 8-bit Unicode strings, the result depends on the current locale.