Reverse the words in a string

In this program, we will take a string as input and reverse the words in a string.

Steps to solve the program
  1. Take a string as input.
  2. Split the string using Split().
  3. Reverse the splitter string using Indexing.
  4. Join the reversed words using join().
  5. Print the output.
				
					#Input string
string="sqatools python"

#Printing output
print(" ".join(string.split(" ")[::-1]))
				
			

Output :

				
					python sqatools
				
			

Check whether the given string is a palindrome (similar) or not.

calculate the length of a string.

Leave a Comment