Please Login in order to post a comment
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')
import re pattern = r'^[+-\.]?[0-9]{0,}\.[0-9]{1,}$' n = int(input().strip()) for _ in range(n): print( bool(re.match(pattern, input().strip())) )
import re for i in range(int(input())): number = input() print(bool(re.search('^[+-]?[0-9]{0,}\.[0-9]+[^A-Z]?$', number)))
import re num_test = int(input()) pattern = re.compile(r'[-+]?\d*\.\d+') for _ in range(num_test): print(bool(pattern.fullmatch(input())))
def isaFloat(string): try: if string == '0': return False float(string.strip()) return True except ValueError: return False for nums in range(int(input())): print(isaFloat(input()))
Seems like cookies are disabled on this browser, please enable them to open this website
Please Login in order to post a comment