A palindrome is a word, phrase, number, or other sequence of characters which reads the same backward as forward. Examples of numerical palindromes are:

2332  
110011  
54322345  

For a given number `num`, write a function to test if it's a numerical palindrome or not and return a boolean (true if it is and false if not).

```if-not:haskell
Return "Not valid" if the input is not an integer or less than `0`.
```
```if:haskell
Return `Nothing` if the input is less than `0` and `Just True` or `Just False` otherwise.
```

Other Kata in this Series:
Numerical Palindrome #1
Numerical Palindrome #1.5
Numerical Palindrome #2
Numerical Palindrome #3
Numerical Palindrome #3.5
Numerical Palindrome #4
Numerical Palindrome #5

Difficulty: introductory

Starter code:

def palindrome(num):
	

Solutions:
def palindrome(num):
    if type(num) is not int or num <1:
        return "Not valid"
    return num == int(str(num)[::-1])

def palindrome(num):
    return str(num) == str(num)[::-1] if type(num) == int and num > 0 else "Not valid"

def palindrome(n):
    try:
        return 1. * n == int(str(n)[::-1])
    except:
        return "Not valid"

def palindrome(n):
    return 'Not valid' if (type(n) != int or n < 0) else str(n) == str(n)[::-1]

def palindrome(a):
    if type(a)==int:
        if a>0:
            a=str(a)
            b=a[::-1]
            if a==b:
                return True
            else:
                return False
        else:
            return "Not valid"
    else:
        return "Not valid"

def palindrome(num):
    if type(num) == int and num > 0:
        return str(num) == str(num)[::-1]
    else:
        return 'Not valid'
        
    # or, as an ugly one line - just for practice:
    
    # return str(num) == str(num)[::-1] if type(num) == int and num > 0 else 'Not valid'


def palindrome(num):
    return 'Not valid' if type(num) is not int or num < 0 else str(num) == str(num)[::-1]

def palindrome(num):
    if type(num) != int or num < 0:
        return "Not valid"
    k = str(num)
    if k == k[::-1]:
        return True
    else:
        return False

def palindrome(num):
    return str(num)[::-1] == str(num) if isinstance(num, int) and num > 0 else 'Not valid'

def palindrome(num):
    if type(123)!=type(num) : return 'Not valid' 
    n = str(num)
    if any(not c.isdigit() for c in n): return 'Not valid'
    l = len(n)
    return all(a==b for a, b in zip(n[:l//2], n[::-1]))

def palindrome(num):
    if type(num) != int or num < 0:
        return "Not valid"
    else:
        return int(str(num)[::-1]) == num

def palindrome(num):
    if not str(num).isdigit():
        return "Not valid" 
    
    if type(num) == str:
        return "Not valid"
    
    num = str(num)
    
    return num == num[::-1]
    # Code here


def palindrome(num):
    if (isinstance(num, int)== False) or (num < 0):
        return 'Not valid'
    else:
        if str(num) == str(num)[::-1]:
            return True
        else:
            return False

def palindrome(num):
    def helper():
        if  type(num) == str or num < 0:
            return  'Not valid'
        return  True if str(num) == str(num)[::-1] else False
    try:
        int(num)
    except ValueError:
        return   'Not valid' 
    else:
        return helper()

def palindrome(n):
    # your code here
    if not isinstance(n, int) or n < 0:
        return "Not valid"
    rev, temp = 0, n
    while temp > 0:
        a = temp % 10
        rev = rev * 10 + a
        temp //= 10
    return rev == n

def palindrome(num):
    return str(num) == str(num)[::-1] if type(num) is int and num >= 0 else 'Not valid'

def palindrome(num):
    if isinstance(num, int) is False or num < 0:
        return "Not valid"
    return str(num) == str(num)[::-1]

def palindrome(n):
    if type(n) == int and n > 0:
        n1,n2 = str(n),str(n)[::-1]
        return n1 == n2
    else:
        return 'Not valid'


def palindrome(num):
    if isinstance(num,int) and num >= 0:
        num = str(num)
        return num == num[::-1]
    else:
        return "Not valid"

class Numerical_paindrom_exception(Exception):
    def __init__(self):
        pass
    def __str__(self):
        return 'Not valid'

def palindrome(num):
    try:
        if type(num) != int or num < 0:
            raise Numerical_paindrom_exception
        return True if str(num)[::1] == str(num)[::-1] else False
    except Exception as e:
        return e.__str__()