1# check if a number is int or float
2
3isinstance(x, int) # integer
4isinstance(x, float) # float
5
6import numbers
7isinstance(x, numbers.Integral) # Long Int
8
1def is_number(x):
2 '''
3 Takes a word and checks if Number (Integer or Float).
4 '''
5 try:
6 # only integers and float converts safely
7 num = float(x)
8 return True
9 except ValueError as e: # not convertable to float
10 return False