The question : https://cs50.harvard.edu/python/2022/psets/3/outdated/
my answer:
while True :
date = input("Date: ").strip().title()
months_list = {
"January": "01",
"February": "02",
"March":"03",
"April":"04",
"May":"05",
"June":"06",
"July":"07",
"August":"08",
"September":"09",
"October":"10",
"November":"11",
"December":"12" }
try:
month , day , year = date.split("/")
month = int(month.strip())
break
except ValueError :
month_day , year = date.split(",")
month , day = date.split(" ")
month = int(months_list[month])
continue
day = int(day.strip())
year = int(year.strip())
print(f"{year:04}-{month:02}-{day:02}")
Can someone please tell me where am I going wrong?
New contributor
Pendragon is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.