Python String Method – Capitalize()

Spread the love

Capitalize() method –

The capitalize method converts the first character of a string to a uppercase letter and all the other characters to a lowercase letters.

Syntax –


Example –

In [1]: s1 = "we love python"

In [2]: s1.capitalize()
Out[2]: 'We love python'

In [3]: s2 = "python is Awesome"

In [4]: s2.capitalize()
Out[4]: 'Python is awesome'

When we use the capitalize method, it does not change the original string. It remains as it is.

In [5]: s1
Out[5]: 'we love python'

In [6]: s2
Out[6]: 'python is Awesome'

Rating: 1 out of 5.

Leave a Reply