0

Can anyone help me find error in my Military Time Code.

I have coded in Python and debugged every line of the code. I think there is some logical error I can't find out https://code.sololearn.com/cChCzvR8Bh5c/?ref=app

24th Apr 2020, 10:52 PM
Md Zakria
Md Zakria - avatar
5 Respuestas
+ 2
Look for the problem outside your code. For example: 11:30 AM => 11:30 12:30 AM => 00:30 Your code is returning 12:30 for 12:30 AM
24th Apr 2020, 11:03 PM
Rik Wittkopp
Rik Wittkopp - avatar
+ 2
Md Zakria 12:00 PM -> 24:00 It should be 00:00 14:00 AM -> 14:00 It should be 02:00
25th Apr 2020, 2:25 AM
Denise Roßberg
Denise Roßberg - avatar
+ 1
Rik Wittkopp I don't think12:30 returning 12:30 is the issue. My code also return same and all 5 tests passed. Infact, my code returns 12:00 PM as 24:00.
24th Apr 2020, 11:24 PM
Tomiwa Joseph
Tomiwa Joseph - avatar
+ 1
Try this simple solution. Split the input as split(':'). Then split the list again, leaving you with three variable to work with: Hour, minutes and am/pm. Then use conditional statement if AM: print hour + ':' minutes. If PM: print hour + 12 + minutes. Try it.
24th Apr 2020, 11:30 PM
Tomiwa Joseph
Tomiwa Joseph - avatar
0
I made changes to the code still it didn't work d=input() b=d.split() a="" if b[1]=='AM': e=b[0].split(":") if e[0]=='12': a+="00:"+e[1] print(a) else: print("".join(b[0])) else: c=b[0].split(":") t=int(c[0])+12 a+=str(t)+":"+c[1] #a+=':' #a+=c[1] print(a)
24th Apr 2020, 11:17 PM
Md Zakria
Md Zakria - avatar