#input of october/9/1701 results in reprompt expected program to reject input
#input of September 8 1636 results in reprompt expected program to reject input
its suppose to reject both input but it keeps reprompting
def main():
outdate()
def outdate():
months =[
"January",
"February",
"March",
"April",
"May",
"June",
"July",
"August",
"September",
"October",
"November",
"December"
]
month = day = year = ""
while True:
date = input("Date: ").strip()
if "/" in date:
month, day, year = date.replace(",", " ").split(" ")
else:
month, day, year = date.replace(",", "").split()
if month in months:
month = months.index(month) + 1
else:
continue
try:
day = int(day)
year = int(year)
month = int(month)
if day > 31 or month > 12:
continue
except ValueError:
pass
break
print(f"{year}-{month:02}-{day:02}")
if __name__ == "__main__":
main()