Home / Python / Reference / String methods

Python string capitalize() method

Capitalise the first character and lower-case the rest.

Syntax

str.capitalize()

Strings cannot change, so this returns a new string; keep it with s = s.capitalize(…).

Parameters

None.

Return value

str

Example

Code

print("hello WORLD".capitalize())
print("python".capitalize())

Output

Hello world
Python

Related

Learn it step by step in the free lesson Strings, with exercises that check your answers.