Answer to Question #21141 in Python for vic

Question #21141
A palindrome is a word that reads the same both forward and backwards. Examples are ‘civic’ ‘racecar’ ‘eye’ and ‘madam’. Create a function called palindrome that takes a single word as a parameter and returns True if the word is a palindrome and False otherwise.
1
Expert's answer
2012-12-26T07:44:22-0500
def palindrome(num):
n=str(num)
whilelen(n)>1:
printn
ifn[0]!=n[-1]:
returnFalse
n=n[1:-1]
returnTrue

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
APPROVED BY CLIENTS