0

I got error in test number 4, please tell me whats wrong with this code

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 https://code.sololearn.com/c484T57fiyc8/?ref=app

19th Jun 2022, 5:32 AM
Dondon Bautista
Dondon Bautista - avatar
4 Respostas
+ 3
Dondon Bautista After the input 1:15 am your code outpts 1:15 and this is wrong. Because should be 01:15 Try to touch this up.
19th Jun 2022, 8:37 AM
JaScript
JaScript - avatar
+ 1
PanicS Bro This is rhe final answer and it work time = input().upper() x = time.split(":") y = time.split() if y[1] == "AM": print(y[0]) elif y[1] == "PM": mil = (int(x[0])+12) print(time.replace(x[0], str(mil)).replace("PM", ""))
19th Jun 2022, 11:46 AM
Dondon Bautista
Dondon Bautista - avatar
0
PanicS Thanks bro i appreciated
19th Jun 2022, 9:34 AM
Dondon Bautista
Dondon Bautista - avatar
0
JaScript thanks bro
19th Jun 2022, 10:08 AM
Dondon Bautista
Dondon Bautista - avatar