Detect Floating Point Number

  • + 0 comments
    import re
    
    n = int(input())
    cases = [input() for i in range(n)]
    
    pattern = r"^[+-]?\d*\.\d+$"
    result = [bool(re.match(pattern, c)) for c in cases]
    
    for r in result:
        print(r)