Use Python built-in capitalize() method to capitalize the first letter of a sentence and change the rest of the characters into lowercase.
This method is used on string data in various ways without just capitalizing on the first characters.
Example of capitalizing the first letter of every sentence in Python
The capitalize() doesn’t take any argument and returns a new string after modifying. It doesn’t change the original string sentence.
For example, a sentence starts with the lowercase letter and contains one word with the first uppercase letter.
myString = 'welcome to Python programing' # Convert the string by capitalize method new_str = myString.capitalize() print(new_str)
Do comment if you have any doubts and suggestions on this Python capitalize code.
Note: IDE: PyCharm 2021.3 (Community Edition)
All Python Examples are in Python 3, so Maybe its different from python 2 or upgraded versions.
Degree in Computer Science and Engineer: App Developer and has multiple Programming languages experience. Enthusiasm for technology & like learning technical.