Python String capitalize() Method

Example

Capitalize the first letter of this sentence:

txt = "hello, and welcome to my world."
x = txt.capitalize()
print (x)

Run Instance

Definition and Usage

The capitalize() method returns a string with the first character in uppercase.

Syntax

string.capitalize()

Parameter Value

No Parameters

More Examples

Example

See what happens when the first character is a number:

txt = "63 is my age."
x = txt.capitalize()
print (x)

Run Instance