Python Capitalize First Letter


Hi there, In this tutorial, we will learn about python capitalize first letter. In python programming, capitalization is a method to capitalize on the first word of the sentence. The first word of the sentence is to capitalize whenever this function required.

Python Capitalize First Letter

In python capitalize first letter is the method of capitalization for the first character of the first word of the given sentence. It is mostly used to check the file is Grammarly correct or not. The syntax of the python capitalize first letter is:

Syntax : string.capitalize()

Parameter : For capitalization of first letter, capitalize() method doesn’t take any parameter.

Return Value : The capitalize() method only return the string value with capitalization of the the first letter of the given string.

Examples of python capitalize first letter

Example 1:

Python capitalize first letter example

Code

#take a sentence without capitalization
string = 'this is my home'

#capitalize the first character of the sentence
string.capitalize()
Output : This is my home

In the above example, The given string is ‘this is my home’, in this string the first word is in lower case. By using capitalize() method the first character of first letter of the sentence can be in the upper case. As you can see in the output of the given example. The output is This is my home.

Example 2:

python capitalize first letter example 2

Code

#take a sentence without capitalization
string = 'technoelearn'

#capitalize the first character of the sentence
string.capitalize()
Output : Technoelearn

As you can see in the above example, The python capitalize first letter are works as the capitalization of only, first letter of the sentence. In Example 2, the given string is technoelearn. By using capitalize() method, the output is Technoelearn. In which the capitalization works for the first letter.


Video Tutorial for python capitalize first letter

How to Capitalize the first letter in python?

python capitalize first letter example 2

Here we will learn, the capitalization of first letter in python. the capitalize() method is used to capitalize the first letter of the sentence. The syntax of capitalization is string.capitalize().

Step 1:

Take a sentence in variable string.

Step 2:

Use capitalize() method for capitalization of first letter of the given string.

Step 3:

For capitalization, use the syntax string.capitalize().


FAQ for Python Capitalize First Letter

What is python capitalization of first letter?

capitalization is the method of capitalizing the first letter of the sentence by using capitalize() method. The syntax of capitalize of the first letter in python is string.capitalize().

How capitalize() method works?

In python programming, The capitalize() method is used to capitalize the first letter of the string. For example, if string = ‘money’ then by using string.capitalize() method the first letter became in uppercase like the output Money.

Learn More Python Programming Language

If you have any queries regarding python capitalize first letter then ask on the comment section, I am happy to answer your question

2 thoughts on “Python Capitalize First Letter”

Leave a Comment

Share via
Copy link
Powered by Social Snap