Python String capitalize() Method Tutorial

In this section, we will learn what String capitalize() method is and how to use it in Python.

What is String capitalize() Method in Python?

The Python String capitalize() method is used to capitalize the first character of a string value.

Python String capitalize() Method Syntax:

stringValue.capitalize()

String capitalize() Method Parameter

The method does not take an argument.

String capitalize() Method Return Value

The return value of this method is a copy of the target string value with the first character capitalized. So this means the original string value won’t change.

Example: using capitalize() method in Python

s1 = "this is a string value"

result = s1.capitalize()

print(result)

Output:

This is a string value

FAQ:

How to capitalize all letters in word?

In order to capitalize or basically turn all the letters into uppercase, we can use the python string upper () method.

Facebook
Twitter
Pinterest
LinkedIn

Top Technologies