First let us try to understand what is Palindrome:
A palindrome is a word, phrase, number, or other sequence of symbols or elements that reads the same forward or reversed, with general allowances for adjustments to punctuation and word dividers.
First Method:
FirstString="ABCDEFFEDCBA"
Reversed=(FirstString [::-1])
if list(FirstString) == list(Reversed):
print("It is Palindrome")
else:
print("It is not Palindrome")
Second Method:
SecondString="1234ABCCBA4321"
def palindrome(num):
return num == num[::-1]
if palindrome(SecondString) == True:
print("It is palindrome")
else:
print("It is not palindrome")
You can try to run this code on Codebunk. You can refer to my Codebunk. These are simple code which can be used in complex algorithm.
More suggestion are always welcome. In case if you wish me to write about any specific scenario, please feel free to write to me or else you can Comment below.
No comments:
Post a Comment