Capitalize String Method in Python

  • Post category:String

In this article, you will see how to capitalize string in Python. String capitalization is the process of changing the first letter of a string to uppercase. In Python, you can use the capitalize() method to capitalize a string.

Step 1: Create a string

str = "codeallow"
print("str = ", str)
print("str type = ", type(str))

Step 2: Capitalize the string

print("Capitalized = ", str.capitalize())


str =  codeallow
str type =  <class 'str'>
Capitalized =  Codeallow

Free resources to learn advanced skills: AiHints and CodeAllow