Madhan Umk
Oct 17, 2023

Write a program in Python to check if a String is Palindrome or Not.

def check_palindrome(word):
#method 1 return "palindrome" if word[::-1].lower() == word.lower() else "not palindrome"

'''
method 2
reversed_word = ""
for i in reversed(range(0,len(word))):
reversed_word +=word[i]
return "palindrome" if reversed_word.lower() == word.lower() else "not palindrome"
'''

#method 3
reversed_word = ""
for i in range(len(word),0,-1):
reversed_word +=word[i-1]
return "palindrome" if reversed_word.lower() == word.lower() else "not palindrome"



words_list = ["Dad","Madhan","Malayalam","Mom","Python"]
for word in words_list:
print(f'The given word "{word}" is {check_palindrome(word)}.')



#Result
The given word "Dad" is palindrome.
The given word "Madhan" is not palindrome.
The given word "Malayalam" is palindrome.
The given word "Mom" is palindrome.
The given word "Python" is not palindrome.
Write a program in Python to check if a String is Palindrome or Not.
Madhan Umk
Madhan Umk

Written by Madhan Umk

90's Kid | Travel Blogger | #lyriclens | Photophile | Founder @lifeliker_in 🪄

No responses yet