Military time doubt | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Military time doubt

Hi, I'm trying to complete the code trainer, and I can't finish the challenge "Military Time". I tried every single possible input (I think) and the output is correct, but there are 2 cases that don't work, and I don't know what to change for the code to work. My code is: hour = input().split(" ") if hour[1] == "PM": morning = False else: morning = True if morning: print(hour[0]) else: hour = hour[0].split(":") hour[0] = str(int(hour[0]) + 12) if hour[0] == "24": hour[0] = "00" print(hour[0] + ":" + hour[1])

26th Dec 2020, 8:50 PM
Soul
5 Answers
+ 2
12:15 AM -> 12:15 (should be 00:15) 12:15 PM -> 00:15 (should be 12:15)
26th Dec 2020, 11:38 PM
Russ
Russ - avatar
+ 2
I'm saying the input of 12:15 AM should return 00:15, not 12:15 as your code outputs.
27th Dec 2020, 4:10 PM
Russ
Russ - avatar
+ 2
👍
27th Dec 2020, 4:43 PM
Russ
Russ - avatar
0
That's already covered, after I added 12, obtaining 24, I transformed that 24 to 00
27th Dec 2020, 4:06 PM
Soul
0
Oh god I did it changed!😅 Tysm
27th Dec 2020, 4:41 PM
Soul