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.