[Solved] Military Time | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

[Solved] Military Time

2/5 test cases failed, and unable to figure out why. Any suggestions? https://code.sololearn.com/cGafztGYCBQ2/?ref=app

26th Feb 2020, 5:09 PM
Dodla Dileep Reddy
Dodla Dileep Reddy - avatar
7 Answers
+ 1
You should check the zfill function! But be careful: There's and extra character in time[:-2] which is the space between the time and AM.
26th Feb 2020, 6:18 PM
LDSD
LDSD - avatar
+ 2
When I write 3:15 AM I should get 03:15, but I'm getting 3:15.
26th Feb 2020, 5:16 PM
HonFu
HonFu - avatar
+ 1
Thanks LDSD, that extra space didn't mattered but zfill worked for me. [Updated the code]
26th Feb 2020, 6:38 PM
Dodla Dileep Reddy
Dodla Dileep Reddy - avatar
+ 1
And HonFu thank you too, I got to know lately what you meant, until then I was debugging the wrong part of 'if', my bad.
26th Feb 2020, 6:43 PM
Dodla Dileep Reddy
Dodla Dileep Reddy - avatar
0
Thanks Mirielle👽, I was just trying naive approach without any modules. But yeah I will start to use this module.
26th Feb 2020, 6:34 PM
Dodla Dileep Reddy
Dodla Dileep Reddy - avatar
0
Yeah Mirielle👽, I agree with you, but when I started solving this challenge I was like I gotta apply my knowledge of slicing. Now that I solved with the help of you guys, I will try using the relevant module. Not just this, but all.
26th Feb 2020, 6:59 PM
Dodla Dileep Reddy
Dodla Dileep Reddy - avatar
0
Thanks a lot LDSD, I googled it and that worked for me 👌
12th May 2020, 8:18 PM
César Vázquez Valencia
César Vázquez Valencia - avatar