+ 2

Military Time code challange (challange bug or hidden problem in my code?)

In this challange we should change the 12 hours clock to 24 hours clock. Sample input == 1:30 PM Sample output == 13:30 My code👇👇 time = input() if time[-2:] == "PM" : conv = int(time[:-6]) + 12 print(str(conv) + time[-6:-3]) else: print(time[:-3]) It doesn't work for some hidden test cases so I don't know what is the problem but I tested it in my ide(on pc) and it worked just fine. I'm so confused!

13th Sep 2020, 11:12 AM
pedram ch
pedram ch - avatar
2 odpowiedzi
+ 1
For input 12:00 AM, output shloud be 00:00 For 12:00 PM => 12:00 For single digit input like 1:00 AM, output should be 01:00 (display 2 digits 0 appended..)
13th Sep 2020, 12:03 PM
Jayakrishna 🇮🇳
+ 1
Jayakrishna🇮🇳 yes you are right I didnt noticed that thank you for your assistance I really appreciate it
13th Sep 2020, 12:32 PM
pedram ch
pedram ch - avatar