Python String – capitalize() method

This is a string method that returns the first character to uppercase of the given string. It keeps rest of all the characters to lower case.

Syntax:

string.capiltalize()

Example 1:

s = “codewindow is a tech website.”
x = s.capitalize()
print(x)

Output:

Codewindow is a tech website.

Explanation:

Here the first character of the string is capitalized.

Example 2:

s = “codewindow. It is a tech Website.”
x = s.capitalize()
print(x)

Output:

Codewindow. it is a tech website.

Explanation:

It returned the first character to upper case and rest of all the characters are converted to lower case.

Example 3:

s = “19 is my age
x = s.capitalize()
print(x)

Output:

19 is my age

Explanation:

If the string starts with a digit or any character except an alphabet, it doesn’t make changes.

You Missed