Detect Floating Point Number

  • + 0 comments

    T = int(input())

    for n in range(1, T+1):

    skip_rest = False
    string_value = input()
    
    try:
        float(string_value)
    except ValueError:
        print(False)
        continue
    
    split_string_value = list(string_value)
    
    count = 0
    Is_alpha = 0
    for j in string_value:
    
        if j == ".":
            if j == string_value[-1]:
                print(False)
                skip_rest = True
                break
            count += 1
        if j.isalpha() is True:
            Is_alpha += 1
    
    if skip_rest is True:
        continue
    elif count== 1 and Is_alpha == 0:
        print(True)
    else:
        print(False)