Python Capitalize() function is used to convert the first character in uppercase, and the rest is lower case. Actually, this method returns a copy of the original string with the first character of the string to a capital other characters in the string lowercase letters.
Note: It doesn’t modify the original string.
Example how to use Capitalize() function in Python
Simple example code Capitalize a Sentence.
s = "python Is beSt." res = s.capitalize() print(res)
Let’s See what happens if the first character is a number:
txt = "100 is my age." res = txt.capitalize() print(res)
Output: 100 is my age.
Do comment if you have any doubts or suggestions on this Python function 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.