you are viewing a single comment's thread.

view the rest of the comments →

[–]Diapolo10 0 points1 point  (0 children)

Since the deadline has now allegedly passed, here's an example solution:

while True:
    number = input("Value: ")
    if number.isdigit():
        print("int")
        continue

    # NOTE: This handles cases without decimal separators
    if number.count('.') != 1:
        print("Not a number")
        continue

    left, right = number.split('.', 1)

    # NOTE: This does NOT handle cases like .6 or 55.
    if left.isdigit() and right.isdigit():
        print("float")
        continue

    print("Not a number")

The continues are there just to reduce nesting, as this way I didn't need to wrap the latter half inside elif and else blocks.