0

Military time problem. I don't know why my code is failing.. any help will be appreciated ✊

You want to convert the time from a 12 hour clock to a 24 hour clock. If you are given the time on a 12 hour clock, you should output the time as it would appear on a 24 hour clock. Task: Determine if the time you are given is AM or PM, then convert that value to the way that it would appear on a 24 hour clock. Input Format: A string that includes the time, then a space and the indicator for AM or PM. Output Format: A string that includes the time in a 24 hour format (XX:XX) Sample Input: 1:15 PM Sample Output: 13:15 My solution: https://code.sololearn.com/cWC5pQ3p9nxc/?ref=app

9th Dec 2021, 8:29 PM
Paul Eboselume
Paul Eboselume - avatar
4 Réponses
+ 1
Paul Eboselume Hi! I found your Errors. It was two. I corrected them, tested the code and it passed code coach test: (1) You must allow both uppercase and lowercase letters in input for AM and PM. (2) You must allow to input (at least) the hours for both one and two digits, like 4:23 and 04:23. Once you’ve fixed these problems, the code will pass. When I tested your solution, I temporarily fixed those error, but it’s not a very nice solution (more of a quick fix). The nice solution is up to you to fix! https://code.sololearn.com/c86MvqfP6Qza/?ref=app
11th Dec 2021, 7:47 AM
Per Bratthammar
Per Bratthammar - avatar
+ 3
Paul Eboselume , it seems that you should add "0" in the hour when hour <= 9(for example 09:15 instead of 9:15). It's mentioned that the output format should be 2 digits for hour and two digits for minutes.
9th Dec 2021, 8:38 PM
TheWh¡teCat 🇧🇬
TheWh¡teCat 🇧🇬 - avatar
+ 1
Per Bratthammar thanks 😊
11th Dec 2021, 6:05 PM
Paul Eboselume
Paul Eboselume - avatar
0
Yeah, I'm aware of that TheWh¡teCat 🇧🇬 and my code covers that but it's still failing for some reason I don't know
10th Dec 2021, 10:50 AM
Paul Eboselume
Paul Eboselume - avatar