Exchange first & last letters of the string

In this program, we will take a string as input and exchange first & last letters of the string

Steps to solve the program
  1. Take a string as input.
  2. Exchange the first and last letters of the string using Indexing.
  3. Print the output.
				
					#Input string
string1= "We are learning python"

#Printing output
print(string1[-1]+string1[1:-1]+string1[0])
				
			

Output :

				
					ne are learning pythoW
				
			

check if a string has a special character or not

convert all the characters in a string to Upper Case.

Leave a Comment