natural: [0, 1, 2 ... ∞]
Python 2
it_is = unicode(user_input).isnumeric()
Python 3
it_is = str(user_input).isnumeric()
integer: [-∞, .., -2, -1, 0, 1, 2, ∞]
try:
int(user_input)
it_is = True
except ValueError:
it_is = False
float: [-∞, .., -2, -1.0...1, -1, -0.0...1, 0, 0.0...1, ..., 1, 1.0...1,
..., ∞]
try:
float(user_input)
it_is = True
except ValueError:
it_is = False