CS50P PS3 outdated.py exercise - deciphering check50 frowny smiley and comment

Viewed 34

So I did a sort of lazy solution of the PS3 outdated exercise by making use of a library related to working with dates and times (trying not to spoiler anything here).

Unless I am missing something, my program works as it should. However, check50 gives me a :( on one query:

:( input of " 9/8/1636 " outputs 1636-09-08 Did not find "1636-09-08" in "Date: "

So my code returns "1636-09-08" if the user inputs "9/8/1636" which seems right to me. Can anyone shed some light on how to interpret the second line of check50's output? Thanks.

1 Answers

I can't remember the question exactly but here is my solution.

`months = [ "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December" ]

convert valid user date to output

try: month, day, year = input("Date: ").split("/")

if int(month) < 10:
    month = f"0{month}"

if int(day) < 10:
    day = f"0{day}"

# split on /
print(f"{year}-{month}-{day}")

except: str_date = input("Date: ") print(str_date)`

Related