Detect Floating Point Number

  • + 0 comments
    import sys, re
    
    N = sys.stdin.read()
    N = N.splitlines()[1:]
    
    pattern = r"^[+-.]?\d*[.]\d+$"
    
    for line in N:
        match = re.search(pattern, line)
        if match != None:
            print('True')
        else:
            print('False')