Thursday, September 4, 2025
HomeLanguagesstring capitalize() in Python

string capitalize() in Python

Python String capitalize() method returns a copy of the original string and converts the first character of the string to a capital (uppercase) letter, while making all other characters in the string lowercase letters.

Python String capitalize() Method Syntax

Syntax: string_name.capitalize()

Parameter:  The capitalize() function does not takes any parameter. 

Return: The capitalize() function returns a string with the first character in the capital.

Python String capitalize() Method Example

Python




name = "Lazyroar FOR Lazyroar"
 
print(name.capitalize())


Output:

Geeks for Lazyroar

Example 1: capitalize() only capitalizes the first letter of a string and lowers all the remaining characters

Python3




string = "roses are red"
print("Original string:", string)
print("After using capitalzie:", string.capitalize())


Output:

Original string: roses are red
After using capitalzie: Roses are red

Example 2: Python String capitalize() Method Doesn’t Modify the Original String

Python String capitalize() Method creates and returns a copy of the original string after modifications.

Python3




string = "Lazyroar for Lazyroar"
string_2 = string.capitalize()
 
print("New string after using capitalize():", string_2)
 
print("Original string:", string)


Output:

New string after using capitalize(): Geeks for Lazyroar
Original string: Lazyroar for Lazyroar
RELATED ARTICLES

Most Popular

Dominic
32261 POSTS0 COMMENTS
Milvus
81 POSTS0 COMMENTS
Nango Kala
6626 POSTS0 COMMENTS
Nicole Veronica
11795 POSTS0 COMMENTS
Nokonwaba Nkukhwana
11855 POSTS0 COMMENTS
Shaida Kate Naidoo
6747 POSTS0 COMMENTS
Ted Musemwa
7023 POSTS0 COMMENTS
Thapelo Manthata
6695 POSTS0 COMMENTS
Umr Jansen
6714 POSTS0 COMMENTS