In [2]:

capitalize()

2025-05-29 13:18

Converts the first character to uppercase.

capitalize()

text = "hello world"
print(text.capitalize()) # Output: 'Hello world'

 

**Description:**
Converts the first character of a string to uppercase and the rest to lowercase.

**Example:**
“`python
text = “hello world”
print(text.capitalize()) # Output: ‘Hello world’
“`

**Use Case:**
Useful for formatting strings, especially when dealing with titles or sentences.