You are viewing a single comment's thread. Return to all comments →
n = int(input()) lines = [input() for _ in range(n)] regex = r"^\(?([+-]?(?!0)\d+?(?:\.\d+?)?),\s([+-]?(?!0)\d+(?:\.\d+)?)\)?$" for line in lines: match = re.match(regex, line) if match: lng = float(match.group(1)) lat = float(match.group(2)) if (-90 <= lng <= 90) and (-180 <= lat <= 180): print("Valid") else: print("Invalid") 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 →