Python Program to Check if a String is a Float Number
# Check if a String is a Float Number in Python def isfloat(num): try: float(num) return True except ValueError: return False # isfloat(), float() tries to convert num to float. If it is successful, then the function returns True. print(isfloat('f5')) print(isfloat('12.345'))
Output:
False
True