Header Ads

Python - WAP to Check if a Number is Palindrome or Not in Python - 06


This is Python Code to Check if the Number is Palindrome or Not in Python 3.5

Source Code:

#!/usr/bin/python3

while True:

    num = int(input("Enter a Number : "))

    rev = 0
    n = num

    while (num > 0):
        rem = num % 10
        rev = rev * 10 + rem
        num = num // 10

    if (rev == n):
        print ("Num '%d', is a Palindrome!" % (n))
    else:
        print ("Num '%d', is Not a Palindrome!" % (n))

    print ("- Codegig.org")

    if (input("To Continue ['y'/n] ")) == 'y':
        continue
    else:
        break

Program Output:

....

No comments