In this program, we will take a string as input and capitalize first and last letters of each word.
Steps to solve the program
- Take a string as input.
- Capitalize first and last letters of each word using Indexing and upper() function.
- Print the output.
#Input string
string = "this is my first program"
for char in string.split(" "):
#Printing output
print(char[0].upper() + char[1:-1] +
char[-1].upper(), end=" ")
Output :
ThiS IS MY FirsT PrograM