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
5 Answers
+ 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
+ 2
Md Zakria
12:00 PM -> 24:00
It should be 00:00
14:00 AM -> 14:00
It should be 02:00
+ 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.
+ 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.
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)