Facebook Page Twitter Page LinkedIn Page
× Python Tutorial Python Advanced Python Resources Python Libraries


The Python String capitalize() method is used to return the string with first character of the specified string into uppercase and rest into lowercase. Any symbol, space, special character or number in the string is ignored while applying this function. Only Alphabets are converted. Please note that it does not change the original string and only returns the converted version of the given string.

Syntax

string.capitalize()

Parameters

No parameter is required.

Return Value

Returns the string with first character of the specified string in uppercase and rest into lowercase.

Example:

In the below example, capitalize() method is used to convert first character of the string called MyString into uppercase and rest into lowercase. This method does not change the MyString and only returns the converted version of it.

MyString = "heLLo woRld!"
NewString = MyString.capitalize()

print(MyString)
print(NewString)

The output of the above code will be:

heLLo woRld!

Hello world!

❮ Python String Methods