In Python, string
capwords() method is used to capitalize all the words in the string using
Syntax: string.capwords(string, sep=None)
Return Value: Returns a formatted string after above operations.
Split the argument into words using split, capitalize each word using capitalize, and join the capitalized words using join. If the optional second argument sep is absent or None, runs of whitespace characters are replaced by a single space and leading and trailing whitespace are removed, otherwise sep is used to split and join the words.
Code #1: If sep parameter is left None.
Python Is One Of The Best Programming Languages.
Code #2: When sep is not None.
When sep = "g" Python is one of the best progRamming langUagEs. When sep = "o" PythoN is oNe oF the best proGramming languages.
- Python String | lstrip() method
- Python String Title method
- Python String | islower() method
- Python String | isupper() method
- Python | Check if given string can be formed by concatenating string elements of list
- String slicing in Python to check if a string can become empty by recursive deletion
- Python | Merge Tuple String List values to String
- Python - Length of shortest string in string list
- Python | Sorting string using order defined by another string
- Python | Check if string ends with any string in given list
- Python | Sort each String in String list
- String slicing in Python to rotate a string
- Python | Check if a given string is binary string or not
- Python String
- Python | Add one string to another
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to email@example.com. 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.