Given the string, the task is to capitalise the first and last character of each word in a string.
Input: hello world Output: HellO WorlD Input: welcome to geeksforgeeks Output: WelcomE TO GeeksforgeekS
- Access the last element using indexing.
- Capitalize the first word using
- Then join the each word using
- Perform all the operations inside lambda for writing the code in one-line.
Below is the implementation.
String before: welcome to geeksforgeeks String after: WelcomE TO GeeksforgeekS
- How to capitalize first character of string in Python
- Pandas - Convert the first and last character of each word to upper case in a series
- Capitalize first letter of a column in Pandas dataframe
- string capitalize() in Python
- numpy.defchararray.capitalize() in Python
- Python | Pandas Series.str.capitalize()
- PyQt5 QSpinBox - Making text capitalize
- PyQt5 QSpinBox – Checking if text is capitalize ?
- Python program to read file word by word
- Python program to find the character position of Kth word from a list of strings
- Find frequency of each word in a string in Python
- Queries to find the last non-repeating character in the sub-string of a given string
- Python program to find occurrence to each character in given string
- Find the first repeated word in a string in Python using Dictionary
- Python - Separate first word from String
- Python program to Extract string till first Non-Alphanumeric character
- Python program to interchange first and last elements in a list
- Python | Reverse each word in a sentence
- Python | Count occurrences of each word in given text file (Using dictionary)
- Python program to read character by character from a file
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to firstname.lastname@example.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.