ItSolutionStuff.com

How to Capitalize String in Python?

By Hardik Savani • October 30, 2023
Python

Hello Developer,

In this example, I will show you how to capitalize string in python. you can see how to capitalize first letter in python. This tutorial will give you a simple example of python string capitalize example. I explained simply about python string capitalize example. you will do the following things for how to use string capitalize in python.

There is a way to convert a string into capitalizing in python. i will give you one example using capitalize() method to python capitalize first letter of sentence. so let's see the below examples.

You can use these examples with python3 (Python 3) version.

let's see below a simple example with output:

Example 1:

main.py

myString = "this is a dog"
  
# String Convert to capitalize
capString = myString.capitalize()
  
print(capString);

Output:

This is a dog

I hope it can help you...

Tags: Python
Hardik Savani

Hardik Savani

I'm a full-stack developer, entrepreneur, and founder of ItSolutionStuff.com. Passionate about PHP, Laravel, JavaScript, and helping developers grow.

📺 Subscribe on YouTube

We Are Recommending You

Python Create an Empty Text File Example

Read Now →

Python String Convert to Lowercase Example

Read Now →

Python String Convert to Uppercase Example

Read Now →

Python List Add Element at Beginning Example

Read Now →

How to Add Element at the End of List in Python?

Read Now →

Python Convert List into String with Commas Example

Read Now →

How to Convert List into String in Python?

Read Now →

Python Split String into List of Characters Example

Read Now →

How to Convert String into List in Python?

Read Now →

Python Remove Empty String from List Example

Read Now →

Python Post Request with Bearer Token Example

Read Now →

Python Get First Date of Next Month Example

Read Now →

Python Create Zip Archive from Directory Example

Read Now →