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.

Expert's answer

def palindrome(num):
n=str(num)
whilelen(n)>1:
printn
ifn[0]!=n[-1]:
returnFalse
n=n[1:-1]
returnTrue
LATEST TUTORIALS
APPROVED BY CLIENTS