+ 1
code coach:Day of the Week
I am trying to answer this question for 8 days but i can’t😭 please help me
4 ответов
+ 2
thank you very much.i’ll see it you recommend.
+ 2
I just saw it! Amazingly easy to understand
+ 1
import re
from datetime import datetime
#from datetime import date
#timestamp_str1 = 'Jul 31,2018'
#timestamp_str2 = '11/19/2019'
a = input()
if re.match(r'\w*\s\d*,\d*',a):
dt = datetime.strptime(a,'%b %d,%Y')
print(dt.strftime('%A'))
else:
date_str=datetime.strptime(a,"%m/%d/%Y")
print(date_str.strftime('%A'))
+ 1
Maybe this link helps you:
https://www.programiz.com/JUMP_LINK__&&__python__&&__JUMP_LINK-programming/datetime/strftime
You will get the full month name like February, so you need %B
I am not sure if you need leading zeros in date or month (01 instead of 1)
Month Day, Year vs. MM/DD/YYYY -> would it not be enough just to check if the input contains a comma or not?