str.capitalize
Make the first character of the string uppercase and the rest lowercase.
Python 3.13
str.capitalize()Return value
A new string; the original is not changed.
Examples
Capitalizing the first letter
Python 3.13
print('hello world'.capitalize())Hello world
Other letters become lowercase
Python 3.13
print('hello WORLD'.capitalize())Hello world
Details
Unlike str.title, only the first letter of the whole string becomes uppercase. If the string does not start with a letter, for example with a space, the result has no uppercase letters: " hello".capitalize() gives " hello".
