You are currently viewing a revision titled "palindrome program code", saved on May 26, 2013 at 1:10 pm by Anne Menmou | |
---|---|
Title | palindrome program code |
Content | # program to test if a word is a palindrome
# the palindrome is a word that is equal to his mirror
# function that takes a string as an argument and store the miror in a variable
def mirror(word):
lengh=len(word)
result=""
while lengh>0:
letter=word[lengh-1]
result=result+letter
lengh=lengh-1
return result
a=input('Enter a word : ')
#print("")
#
#print("")
b=mirror(a)
if a==b:
print(a, "is a palindrome")
else:
print(a, "is not a palindrome") |
Excerpt | |
Footnotes |