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
Output:
Well found bugs, feel free to report them !
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:
Comments
Post a Comment