In Python, the capitalize() method converts the first character of a string to capital (uppercase) letter. If the string has its first character as capital, then it returns the original string.
Syntax:
string_name.capitalize()
string_name: It is the name of string of
whose first character we want
to capitalize.
Parameter: The capitalize() function does not takes any parameter.
Return value: The capitalize() function returns a string with the first character in capital.
Below is the python program to illustrate capitalize() function:
# Python program to demonstrate the # use of capitalize() function # capitalize() first letter of # string. name = "geeks for geeks"
print(name.capitalize())
# demonstration of individual words # capitalization to generate camel case name1 = "geeks"
name2 = "for"
name3 = "geeks"
print(name1.capitalize() + name2.capitalize()
+ name3.capitalize())
|
Output:
Geeks for geeks GeeksForGeeks
Attention geek! Strengthen your foundations with the Python Programming Foundation Course and learn the basics.
To begin with, your interview preparations Enhance your Data Structures concepts with the Python DS Course.
Recommended Posts:
- How to capitalize first character of string in Python
- Python program to capitalize the first and last character of each word in a string
- numpy.defchararray.capitalize() in Python
- Python | Pandas Series.str.capitalize()
- Capitalize first letter of a column in Pandas dataframe
- PyQt5 QSpinBox - Making text capitalize
- PyQt5 QSpinBox – Checking if text is capitalize ?
- String slicing in Python to check if a string can become empty by recursive deletion
- String slicing in Python to rotate a string
- Python | Check if a given string is binary string or not
- Python | Check if given string can be formed by concatenating string elements of list
- Python | Check if string ends with any string in given list
- Python | Sorting string using order defined by another string
- Python | Merge Tuple String List values to String
- Python | Sort each String in String list
- Python | Convert List of String List to String List
- Python - Length of shortest string in string list
- Python - Remove front K characters from each string in String List
- Python - Remove String from String List
- Python | Delimited String List to String Matrix
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.

