Palindrome Program – multiple Python solutions

A palindrome is one such string related python problem that almost all the computer science student try to solve in order to learn how python strings work. A palindrome is a string that reads the same forwards and backward.

A very simple solution for checking palindrome using python string indexing method

word=input("Please enter a word")
if word == revs:
    print("This word is a palindrome")
    print("This word is not a palindrome")

The old fashioned way we can do it like this using for loop

#   Python program to check whether the entered string is palindrome or not. 
#   program by          : rakesh kumar
#   website             :

word = input('Enter any word :')
l = len(word)
found =0
for i in range(0,l//2):

if(found ==1):
    print("not a palindrom")
    print("Its a palindrome")

The output of the above codes are as follows

as@DESKTOP-P84OH09 MINGW64 ~/desktop
$ c:/python37/python.exe c:/Users/as/Desktop/
Enter any word :rakesh
not a palindrom

as@DESKTOP-P84OH09 MINGW64 ~/desktop
$ c:/python37/python.exe c:/Users/as/Desktop/
Enter any word :nitin
Its a palindrome

Do you have more solutions to this problem? Please send us your solution and we would love to add that solution in this article.

Print Friendly, PDF & Email

Related Posts

If you like CBSEToaday and would like to contribute, you can also write an article using submit article or mail your article to See your article appearing on the main page and help other students/teachers.