[Solved] Value is a floating point number python 3 [closed]


You can handle this through a few exceptions, relying on the fact that a failed conversion raises a ValueError:

input_value = input("> ")
try:
    int_value = int(input_value)
    print("invalid input: value was an int!")
except ValueError:
    try:
        float_value = float(input_value)
        print(float_value)  # just echo
    except ValueError as e:
        print("invalid input: ", " ".join(e.args))

(Python 3 inside)

1

solved Value is a floating point number python 3 [closed]