Definition of capitalize() Function
The capitalize() function in Python is used to capitalize the first letter of a string. It turns the rest of all letters to lowercase.
If the first letter is not an alphabet, capitalize() function will not change anything in the string.
String capitalize() Method in Python
Python String capitalize() method returns a copy of the original string and converts the first character of the string to a capital (uppercase) letter while making all other characters in the string lowercase letters.
Example
Python3
# initializing a string name = "draco malfoy" #using capitalize function print (name.capitalize()) |
Output
Draco malfoy