/  Capitalize() method in Python String Module

Capitalize() method in Python String Module

The capitalize() method in Python program converts the first alphabet of the string into uppercase and the all the remaining alphabets to lower case.


Syntax:

string.capitalize()

This method do not have any arguments to provide.


Capitalize() method can be used in alphabetical and non-alphabetical strings.


Below are the Examples:


Example-1:

Use of Capitalize() in alphabetical string:

text= "iam the python developer"
x=text.capitalize()
print (x)


Output:


Example-2:

Use of Capitalize() in non-alphabetical string starting with number:

text='1 is rank of python among programming languages'
x= text.capitalize()
print(x)


Output:


Example-3:

Use of Capitalize() in non-alphabetical string starting with symbol:

text='/ is an operator in Python'
x= text.capitalize()
print(x)


Output: