You are viewing a single comment's thread. Return to all comments →
import re regex = re.compile(r'^\([+-]?[1-9]\d*(\.\d+)?, [+-]?[1-9]\d*(\.\d+)?\)$') for _ in range(int(input())): line = input() if regex.match(line) and all(-90 <= coord <= 90 if index == 0 else -180 <= coord <= 180 for index, coord in enumerate(eval(line))): print('Valid') else: print('Invalid')
Seems like cookies are disabled on this browser, please enable them to open this website
Detecting Valid Latitude and Longitude Pairs
You are viewing a single comment's thread. Return to all comments →