Capitalize first and last letters of each word.

In this program, we will take a string as input and capitalize first and last letters of each word.

Steps to solve the program
  1. Take a string as input.
  2. Capitalize first and last letters of each word using Indexing and upper() function.
  3. 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 
				
			

remove spaces from a given string.

calculate the sum of digits of a given string.

Leave a Comment