overview of String capitalize()
The capitalize() method in Python converts the first character of a string to an uppercase letter. All other characters are converted to lowercase letters.
use of capitalize()
The capitalize() method is used to convert the first letter to an uppercase letter.
# use of capitalize() method
myString = 'pYTHON'
newString = myString.capitalize()
print(newString)
The string myString is capitalized and assigned to the variable newString. Then, the newString is returned.
Python
syntax of capitalize()
The syntax of the capitalize() method is:
string.capitalize()
arguments of capitalize()
The capitalize() method doesn't accept any arguments.
return value of capitalize()
The capitalize() method returns a string with the first letter converted to uppercase and all other characters converted to lowercase letters. The original string remains unchanged, it is recommend to assign the return value to a new variable.