0

Military time code-coach ?

I made the following code for military time problem in code coach, x = input().split(' ') t = x[0].split(':') if x[1]=='PM' and int(t[0])!=12: a = int(t[0])+12 elif x[1]=='AM' and int(t[0])==12: a = '00' else: a = t[0] time = [str(a)] + [':'] + [t[1]] print(''.join(time)) Can anyone tell me, for which input the code will fail?

16th Jan 2020, 2:44 PM
Akash
Akash - avatar
2 ответов
+ 1
Akash Sil The input time is in AM is raising error Input :- 3:45 AM returns 03:45 but your code return 3:45 fix that with same format XX:XX
16th Jan 2020, 3:09 PM
DishaAhuja
DishaAhuja - avatar
0
DishaAhuja thanks
16th Jan 2020, 4:39 PM
Akash
Akash - avatar