+ 1

code coach:Day of the Week

I am trying to answer this question for 8 days but i can’t😭 please help me

8th Feb 2020, 6:34 AM
Modori
Modori - avatar
4 Answers
+ 2
thank you very much.i’ll see it you recommend.
8th Feb 2020, 12:13 PM
Modori
Modori - avatar
+ 2
I just saw it! Amazingly easy to understand
8th Feb 2020, 12:14 PM
Modori
Modori - avatar
+ 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'))
8th Feb 2020, 6:36 AM
Modori
Modori - avatar
+ 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?
8th Feb 2020, 8:56 AM
Denise Roßberg
Denise Roßberg - avatar