Q. Write a function that checks whether an input number is a palindrome or not.

[Note: A number or a string is called palindrome if it appears same when written in reverse order also. For example, 12321 is a palindrome while 123421 is not a palindrome]


Answer :-


num = input("Enter a number :-")

if num == num [ -1 : -len( num )-1 : -1 ] :
    print("Number is palindrome")
else :
    print("Number is not palindrome")


Output :-

Enter a number :-123456
Number is not palindrome

>>> 

Enter a number :-98789
Number is palindrome

>>>

Post a Comment

You can help us by Clicking on ads. ^_^
Please do not send spam comment : )

Previous Post Next Post