1# CHECKING IF INT
2variable='3'
3try:
4 int(variable)
5 # this will execute if it is integer
6 print('You typed an int')
7except ValueError:
8 # otherwise this will execute
9 print('You did not type an int')
10
11# CHECKING IF FLOAT
12variable='3'
13try:
14 float(variable)
15 print('You typed a float')
16except ValueError:
17 print('You did not type a float')
1def isfloat(value):
2 try:
3 float(value)
4 return True
5 except ValueError:
6 return False