0
Tests failing - Military time Python
4 Respuestas
+ 2
Daniel Santos The output format is XX:XX. So it should be 01:42, not 1:42.
+ 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
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.
- 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)