THE WORLD'S LARGEST WEB DEVELOPER SITE

Python String capitalize() Method

❮ String Methods


Example

Upper case the first letter in this sentence:

txt = "hello, and welcome to my world."

x = txt.capitalize()

print (x)
Run example »

Definition and Usage

The capitalize() method returns a string where the first character is upper case.


Syntax

string.capitalize()

Parameter Values

No parameters


More Examples

Example

See what happens if the first character is a number:

txt = "36 is my age."

x = txt.capitalize()

print (x)
Run example »

❮ String Methods