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
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. And to begin with your Machine Learning Journey, join the Machine Learning – Basic Level Course