Detect Floating Point Number

Sort by

recency

|

555 Discussions

|

  • + 0 comments

    Can't we use while !

  • + 0 comments
    import re
    for _ in range(int(input())):
        print(bool(re.fullmatch(r"[+-]?\d*\.\d+",input())))
    
  • + 0 comments
    T = int(input())
    for i in range(T):
        N= input()
        if ('.') in N:
            try:
                N= float(N)
                print(True)
            except:
                print(False)
        else:
            print(False)
    
  • + 0 comments

    here is my solution

    import re l = int(input()) for _ in range(l): N = input() pattern = r"[+-]?\d*.\d+" if re.fullmatch(pattern, N): print("True") else: print("False")

  • + 0 comments

    import re print(("True" if re.match(r'^[+-]?\d.\d+$', input().strip()) else "False" for _ in range(int(input()))), sep='\n')