Python - String capitalize() Method
The Python String capitalize() method returns 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.
No parameter is required.
Returns the string with first character of the specified string in uppercase and rest into lowercase.
In the example below, 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