Use capitalize() method If you want to capitalize the only first letter of a given sentence in Python. This method returns a copy of the original string and converts the first character of the string to capital and rest all other characters in the string lowercase letters.
Example capitalize the first letter in Python
Simple example code capitalizes the first letter only. If the first character is an integer, it will not capitalize the first letter.
txt = 'the brOwn Fox' res = txt.capitalize() print(res)
Use title() function Capitalize the first letter of each word in a string in Python.
txt = 'the brOwn Fox' res = txt.title() print(res)
The Brown Fox
Do comment if you have any doubts or suggestions on this Python capitalize topic.
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.