Knowledge baseExam Center
ENEnglish
Choose language13

CKTIS / Python

str.capitalize

Makes the first character titlecase and the rest lowercase.

Version: Python 3.14; repository image, production runtime not attested

Syntax

s.capitalize()

Makes the first character titlecase and the rest lowercase.

The first character can expand into several characters under Unicode titlecasing.

The first example produces Berlin. The initial sharp s in the second case has the titlecase mapping Ss, while E, T and A turn lowercase, giving Sseta. Uppercasing the sharp s alone would give two capital letters.

Examples

print("bERLIN".capitalize())
print("ßETA".capitalize())

Result

Berlin
Sseta

The first example produces Berlin. The initial sharp s in the second case has the titlecase mapping Ss, while E, T and A turn lowercase, giving Sseta. Uppercasing the sharp s alone would give two capital letters.

Sources