Titlecase String Method in Python

  • Post category:String

In this article, you will see how to titlecase string in Python. The titlecase means converting the first letter of each word to uppercase. In Python, you can use the title() method to titlecase a string.

Step 1: Create a string

str = "code allow"
print("str = ", str)
print("str type = ", type(str))

Step 2: Titlecase string

print("Titlecased = ", str.title())

Output:

str =  code allow
str type =  <class 'str'>
Titlecased =  Code Allow

Free resources to learn advanced skills: AiHints and CodeAllow