Limitations of String title() Method

There are some limitations of string title() function. We have mentioned some of the limitations that you might notice:

Example 1: title() method considers any non-alphabet as a word boundary.

Python3




string = "He's smarter."
expected_string = "He's Smarter"
print("Expected:", expected_string, ", Actual:", string.title())


Output:

Expected: He's Smarter , Actual: He'S Smarter.

Explanation: The ‘s’ after He’ is converted to Capital letter, because after (apostrophe) string title() method considers the start of a new word, since s is the first letter after (apostrophe), thus it makes ‘s’ as capital letter.

Example 2: Different word boundaries other than space, when using title() Method

Here, even though there are no spaces separated words, still Python String title() method converts the String title case considering ‘-‘(hyphen) as word boundaries.

Python3




string = "geeks-for-geeks"
print(string, "converted using title():", string.title())


Output:

geeks-for-geeks converted using title(): Geeks-For-Geeks

Python String Title method

Python String title() method returns a new string after converting the first letter of every word to uppercase(capital) and keeping the rest of the letters lowercase.

Example: Make string title case

Python3




print("usE stRing title Method".title())


Output

Use String Title Method

Similar Reads

String title() Method Syntax

...

What is String title() Method?

string.title()...

More Example on String title() Method

String title() is an in-built function in Python that is used to change text in title format. It converts the first letter of every word to uppercase and other letters to lowercase and then returns this new string....

Limitations of String title() Method

...

Fixing the Limitations of title() Method

Here are some more examples on string title() method, for better understanding:...

FAQ on Python title() method

...