#πŸ”’ Outdated CS50p

9 messages Β· Page 1 of 1 (latest)

glacial flume
#

I am doing the course CS50p by Harvard and there is a problem called outdated and below is the problem attached

Can anyone tell me how to do it but not give the answer i am trying to figure out what to do but i dont get it
At first i thought of finding out if specific things like β€œ-” or months are present by converting the input into list but i have a feeling thats wrong can someone help please

stable jasperBOT
#

@glacial flume

Python help channel opened

Remember to:

  • Ask your Python question, not if you can ask or if there's an expert who can help.
  • Show a code sample as text (rather than a screenshot) and the error message, if you've got one.
  • Explain what you expect to happen and what actually happens.

:warning: Do not pip install anything that isn't related to your question, especially if asked to over DMs.

bright sapphire
#
  1. create a function which parses a date given in 9/8/1636 format - assuming the provided string is in that format
  2. similarly, create a function which parses a date given in September 8, 1636 format
  3. try to call functions (1) and (2), accept the results from whichever function didn't throw an error. If both failed, the input was invalid
  4. use whichever valid results to format the resultant date
#

something like this

try:
  year, month, day = parse_slashes(inputted_value) # 9/8/1636
except:
  pass

try:
  year, month, day = parse_english(inputted_value) # September 8, 1636
except:
  pass

print(f"The date is: {year}-{month}-{day}")
#

I left out the error handling because you only asked for a hint

#

@glacial flume

void hornet
#

wouldn't hurt trying to learn regex for this one I think? try to match the two different formats, if both return nothing, then it's unlikely to be in those formats

stable jasperBOT
#
Python help channel closed

This help channel has been closed and it's no longer possible to send messages here. If your question wasn't answered, feel free to create a new post in #1035199133436354600. To maximize your chances of getting a response, check out this guide on asking good questions.