Product SiteDocumentation Site

8.4. Palindrome പരിശോധിക്കല്‍

Palindrome are the kind of strings which are same from left or right whichever way you read them. Example "madam". In this example we will take the word as input from the user and say if it is palindrome or not.

#!/usr/bin/env python
s = raw_input("Please enter a string: ")
z = [x for x in s]
if s == "".join(z):
    print "The string is a palindrome"
    print "The string is not a palindrome"


[kd@kdlappy book]$ ./
Please enter a string: madam1
The string is not a palindrome
[kd@kdlappy book]$ ./
Please enter a string: madam
The string is a palindrome