Python String title() Method Tutorial

In this section we will learn what String title() method is and how to use it in Python.

What is String title() Method in Python?

The Python string title() method is used to convert the first character of each word in a string value into uppercase.

Note that this method will also convert each character that comes after a digit into uppercase as well.

For example, if you have a word like “t32e25d”, calling this method on it will get you: “T32E25D”.

Python String title() Method Syntax:

string.title()

String title() Method Parameter

The method does not take an argument.

String title() Method Return Value

The return value of this method is a copy of the target string with the first character of each word set to uppercase.

Also, the first character that comes after a digit will be converted to uppercase as well.

Example: python title case with title() method in python

s1= "this is a simple sentence"

result = s1.title()

print(result)

Output:

This Is A Simple Sentence

Example: Title Capitalize in Python with title() Method

s1= "this is a3g3w93 th6sx"

result = s1.title()

print(result)

Output:

This Is A3G3W93 Th6Sx
Facebook
Twitter
Pinterest
LinkedIn

Top Technologies