Ch 43 is_palindrom reverse name is True or False

 #revers the word if name is pralindrom ==true else false

def is_palindrom(word):

new=word[::-1]

if word == new:

return True

else:

return False

name=input("enter anyhig")

print(is_palindrom(name))

#to reverse the word and anu numer we use [::-1] is impo see top to learn more







#in short way to excute same program 

def is_palindrom(word):

if word == word[::-1]:

return True

return False

print(is_palindrom("madam"))

print(is_palindrom("horse"))



#in very short way

def is_palindrom(word):

return word == word[::-1]

print(is_palindrom("madam"))

print(is_palindrom("horse"))

Comments