I am setting up a function in Python to receive a date in the format MM/DD/YYYY, then validate it with a regular expression. This is what I have right now:
def getdate():
date = raw_input("Please enter the date completed (MM/DD/YYY): ")
if re.match(r"\d{2}/\d{2}/\d{4}", date)
break
else:
print "Incorrect date format"
getdate()
The system keeps returning a syntax error pointing at the close parentheses in the "if" line. I can't seem to figure out exactly what it is considering a syntax error. I have also tried this with no success:
def getdate():
date = raw_input("Please enter the date completed (MM/DD/YYY): ")
valid = "(\d{2}/\d{2}/\d{4})"
if re.match(valid, date)
break
else:
print "Incorrect date format"
getdate()
This also returns the same error.
Thanks.