Palindrome checker which accepts both string and numbers

This is a simple program in Python which accepts both string and integer and checks if it is palindrome. Basically this program coverts any input to a string and then performs a reverse string operation. There are two Functions used in this program, firstly rev_str(), which reverse the string passed to it and secondly palstr() which checks whether the string is palindrome.

Here is the code Snippet

def rev_str(x):
    return x[::-1]
def palstr(x):
    if ( x == rev_str(x)):
        print "Palindrome";
    else:
        print "Not palindrome";

str=raw_input();
palstr(str);


Output:


Well found bugs, feel free to report them !

Comments

Popular posts from this blog

Non Restoring Division Algorithm Implementation in C

Hackerrank Modified Kaprekar Numbers Solution

Bit Stuffing Code Implementation in Java