Detect Floating Point Number

  • + 0 comments

    I believe this works well enough! As pythonic as I could make it.

    import re
    
    N=int(input())
    pattern=r"^[+-]?\d*\.\d+$"
    
    for i in range(N):
        num=input()
        print(bool(re.match(pattern, num)))