Tests failing - Military time Python | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
20th May 2020, 9:23 PM
Daniel Santos
Daniel Santos - avatar
4 Answers
+ 2
Daniel Santos The output format is XX:XX. So it should be 01:42, not 1:42.
20th May 2020, 9:55 PM
Manu_1-9-8-5
Manu_1-9-8-5 - avatar
+ 1
So, now that you both have running solutions, I'll leave mine here also. I'm using zfill, maybe you find it handy for future tasks. https://code.sololearn.com/cR0K13kOIs7f/?ref=app
21st May 2020, 5:44 AM
Manu_1-9-8-5
Manu_1-9-8-5 - avatar
0
Ramin.RX7 I was trying to use the topics I studied so far. Manu_1-9-8-5, you're right, I missed it. Thanks both of you guys.
21st May 2020, 12:07 AM
Daniel Santos
Daniel Santos - avatar
- 1
Oh man you take it easy your code is realy complex. a=input() b=a.replace("AM","").replace ("PM","") ans="" if a[-2:]=="AM": if b[1]==":": print("0"+b[0:]) else: print(b[0:]) else: if b[1]==":": ans=str(int(b[0])+12)+b[1:] elif b[2]==":" and b[0:2]!="12": ans=str(int(b[0:2])+12)+b[2:] else: ans="00"+b[2:] print(ans)
20th May 2020, 9:54 PM
Ramin.RX7
Ramin.RX7 - avatar