Palindrome String

#!/usr/bin/evn python
# Take input from the user
strng = input("Enter your string: ")

# Make it suitable for caseless comparison
strng = strng.casefold()

# Reverse the string
revStrng = reversed(strng)

# Check if the string is equal to its reverse
if list(strng) == list(revStrng):
   print("It is palindrome")
   print("It is not palindrome")

#***** Output *****
Enter your string: asdfaw
It is not palindrome

# or

Enter your string: abcdcba
It is palindrome

Comments (0)

  • To add your comment please or

We use cookies to improve your experience on our site and to show you personalised advertising. Please read our cookie policy and privacy policy.

Got It!