Check whether the string is palindrome or not.

In this python if else program, we will program to check if any given string is palindrome or not.

A string is a palindrome if it remains the same from both ends. When you reverse a string, it is same as the original string.

Hint:
Use indexing.

Steps to solve the program
  1. Take a string as input.
  2. Reverse the given string and store the result in another variable.
  3. Compare both strings using an if-else statement.
  4. If both the strings are equal then the string is palindrome, else string is not palinfrome.
  5. Print the respective output.
				
					str1 = 'jaj'
str2 = str1[::-1]

if str1 == str2:
    print("It is a palindrome string")
else:
    print("It is not a palindrome string")
				
			

Output :

				
					It is a palindrome string
				
			

Related Articles

check whether any given number is a palindrome.

check whether a student has passed the exam

Leave a Comment