+ 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
4 Respuestas
+ 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
+ 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?
+ 2
Ok thanks. Doing that right away
+ 1
Thanks sir.