Swap the last character of a string

In this program, we will take a string as input and swap the last character of a string

Steps to solve the program
  1. Take a string as input.
  2. Swap the last character of a string using Indexing.
  3. Print the output.
				
					#input string
string = "SqaTool"

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

Output :

				
					lqaTooS
				
			

replace the second occurrence of any char with the special character $.

exchange the first and last character of each word

Leave a Comment