Private archive copy · Unofficial site · Content copyright belongs to Runoob Tutorial and the original authors · View Original

Python3 capitalize() Method

Python3 capitalize() Method

Python3 Strings Python3 Strings


Description

Python capitalize() converts the first letter of a string to uppercase and the other letters to lowercase.

Syntax

Syntax of the capitalize() method:


str.capitalize()

Parameters

Return Value

This method returns a string with its first letter capitalized.

Example

The following example demonstrates the capitalize() method:

Example

#!/usr/bin/python3

str

=

"this is string Example From Runoob....wow!!!"

print

(

"str.capitalize() : "

,

str

.

capitalize

(

)

)

The output of the above example is:


str.capitalize() :  This is string example from runoob....wow!!!

Python3 Strings Python3 Strings