+ 1

Code Coach "Military Time"

I can't pass hidden test #3 and #5. What's wrong? input = input().split(' ') pm = {1:'13', 2:'14', 3:'15', 4:'16', 5:'17', 6:'18', 7:'19', 8:'20', 9:'21', 10:'22', 11:'23', 12:'00'} if input[1] == 'AM': input = input[0].split(':') if len(input[0]) < 2: input[0] = list(input[0]) input[0].insert(0, '0') input[0] = str(input[0]) elif input[1] == 'PM': input = input[0].split(':') input[0] = pm[int(input[0])] print(':'.join(input))

9th May 2020, 5:08 AM
kxrxkt
kxrxkt - avatar
6 Antworten
+ 1
12:00 AM must be translated to 00:00 12:00 PM to 12:00 do not use variable names that match operator names, parse data to new variables
9th May 2020, 5:27 AM
Igor Kostrikin
Igor Kostrikin - avatar
+ 1
Googled about 12h time format and understood. Thanks.
9th May 2020, 8:35 AM
kxrxkt
kxrxkt - avatar
+ 1
I fixed that, but still #3 and #5 failed
9th May 2020, 9:18 AM
kxrxkt
kxrxkt - avatar
0
Your code fails with input like this "2:17 AM", result must be 02:17
9th May 2020, 7:29 PM
Igor Kostrikin
Igor Kostrikin - avatar
0
Thanks, solved
10th May 2020, 3:35 AM
kxrxkt
kxrxkt - avatar