- 1
Complete my Code plzzx (Python) "Military Time"
I had successfully done the 1st, 2nd and 4th but the hidden test are incompleted So plzzz help to find the Missing piece of code # militaryTime Coding time = str(input("")) hours = 0; min = 0 l=0 for i in time: l+=1 # for Hours if time[2] == ':': hours = int(time[0])*10 + int(time[1]) else: hours = int(time[0]) # for min for i in range(0, l): if time[i] == ' ' and time[i-3]==':': min = int(time[i-2])*10 + int(time[i-1]) elif time[i] == ' ' and time[i-2]==':': min = int(time[i-1]) if min == 0: min = str("00") for i in time: if i == 'P': hours += 12 if hours == 0: hours = str("00") militaryTime = str(str(hours)+':'+str(min)) print(militaryTime) https://code.sololearn.com/cG25JyZojIoB/?ref=app
1 Antwort
0
12:00 PM should be 00:00 and not 24:00.
And your output has to be always in this form: XX:XX
1:12 AM should be 01:12