In: Computer Science
#Python:
>>>
Please enter a string: eve
Your string "eve" is a palindrome.
>>> testPalindrome()
Please enter a string: end
Your string "end" is not a palindrome.
>>> testPalindrome()
Please enter a string: 100921
Your string "100921" is not a palindrome.
>>> testPalindrome()
Please enter a string: 10401
Your string "10401" is a palindrome.
>>>
I have written the program using PYTHON PROGRAMMING LANGUAGE.
OUTPUT :
CODE :
#function definition for testPalindrome
def testPalindrome(input_string):
temp = list(input_string)#converting string to list
temp.reverse()#to reverse the input string
if(temp == list(input_string)):
return True#return True
else:
return False#return False
#To take the user input for string
input_string = input("Enter a string : \t")
print("\nOUTPUT : ")
#calling testPalindrome function by passing the input string
if(not(testPalindrome(input_string))):
#print statement
print("Your string "+input_string+" is not a Palindrome.")
else:
#print statement
print("Your string "+input_string+" is a Palindrome.")
Thanks..