Python program to check if a string is palindrome or not

Given a string, our task is to check weather this string is palindrome or not.


Step1: Enter string as an input.
Step2: Using string slicing we reverse the string and compare it back to the original string.
Step3: Then display the result.

Example code

my_string=input("Enter string:")
   print("The string is a palindrome")
   print("The string isn't a palindrome")


Enter string:madam
The string is a palindrome
Enter string:python
The string isn't a palindrome

Updated on: 26-Jun-2020

3K+ Views

Kickstart Your Career

Get certified by completing the course

Get Started