I'm writing script for checking if a pair of numbers is a valid coordinate. I need to check if the numbers are expressed as decimals only and in the range of 0 to 180 positive or negative for longitude and 0 to 90 positive or negative for latitude. I have used a try/except block to check if the number is a float like this:
def isFloat(n):
try:
float(n)
return True
except ValueError:
return False
While this mostly works, I want it to accept floats expressed only as decimals and not values like True, False, 1e1, NaN