+ 1

Why does my code work for some cases and not all, can someone help identify why my slicing goes wrong

I have an issue slicing just the month out of the m_d variable in my code which yields the day out or range error. My code works for dates below 2 digits but above it throws out an error please help me out https://code.sololearn.com/c0hf7tGtHrlm/?ref=app

21st Aug 2023, 7:26 AM
Gemuh Hans
4 odpowiedzi
+ 5
Gemuh Hans , a very convenient way to solve this task, is to use the datetime module. see sample in the attached file. you can also find more information about strptime() (parsing input) and strftime() (formatting output) and the related format codes. if spaces or ˋ-ˋ or ˋ/ˋ are required, put them also in the format string. to start, input the date, and parse it with strptime() to match the input with the format codes. if everything runs well, the result is a datetime object. with this we can get any output we like to have. https://code.sololearn.com/c4Y5WFYjy056/?ref=app
21st Aug 2023, 5:18 PM
Lothar
Lothar - avatar
+ 4
Gemuh Hans list index out of range because you are accessing item which is not in the list. index starts with 0 Also at the end check the syntax What is %A?
21st Aug 2023, 8:06 AM
R🍁🇮🇳
R🍁🇮🇳 - avatar
+ 2
Ok thanks. Doing that right away
21st Aug 2023, 8:10 AM
Gemuh Hans
+ 1
Thanks sir.
21st Aug 2023, 5:28 PM
Gemuh Hans