I am trying to figure out the most compact and pythonic way of checking if a variable is a positive integer. This is what I've tried so far.
a = None
b = 3.4
c = -1
d = 10
e = -5.7
f = '7'
g = [9]
h = {7}
i = 3j
j = r'8'
k = True
l = False
varlist = [a, b, c, d, e, f, g, h, i, j , k, l]
for vv in varlist:
print( isinstance(vv, int) )
Current Output
False
False
True
True
False
False
False
False
False
False
True
True
Ideal Output
False
False
False
True
False
False
False
False
False
False
False
False