I'm trying to match a coordinate with a python string regex, but I'm not getting a result. I was to see if the input is a valid coordinate definition but I'm not getting the correct match using the code below. Can someone tell me what's wrong?
def coordinate(coord):
a = re.compile("^(([0-9]+), ([0-9]+))$")
b = a.match(coord)
if b:
return True
return False
Currently, it's returning false even if I pass in (3, 4) which is a valid coordinate.
b = a.match(coord), notb = re.match(coord).TypeErrorbecause of incorrect arguments... So I'm really not sure if we're dealing with the actual code here...return bool(a.match(coord))instead... However, it wouldn't hurt that much to return the match object anyway