Categories
Python Answers

How to capitalize the first letter of each word in a string with Python?

Spread the love

Sometimes, we want to capitalize the first letter of each word in a string with Python.

In this article, we’ll look at how to capitalize the first letter of each word in a string with Python.

How to capitalize the first letter of each word in a string with Python?

To capitalize the first letter of each word in a string with Python, we can use the string’s title method.

For instance, we write

s = "hello world".title()

to call "hello world".title to return "hello world" in title case.

Conclusion

To capitalize the first letter of each word in a string with Python, we can use the string’s title method.

By John Au-Yeung

Web developer specializing in React, Vue, and front end development.

Leave a Reply

Your email address will not be published. Required fields are marked *