Write a python function to capitalize first and last letters of each word of a given string


Topic: Write a python function to capitalize first and last letters of each word of a given string

Solution

capitalize_both_ends = lambda x: x[0].upper() + x[1:-1] + x[-1].upper()
def capitalize_first_and_last(string):
    string = string.strip().split()
    new_string = [capitalize_both_ends(word) for word in string]
    return new_string
        



List all Python Programs