0

Problem with military time challenge

Can anyone help identify what the problem is with this code? time=input() hours,mins=time.split(":") plus=int(hours)+12 if "PM" in time: time=time.replace("PM","") if int(hours)<12: time=time.replace(hours,str(plus)) elif "AM" in time: time=time.replace("AM","") if int(hours)<10: if "0" not in hours: time=time.replace(hours,"0"+ hours) elif int(hours)==12: time=time.replace(hours,"00") print(time.strip())

27th Jan 2021, 7:34 AM
Evans Enweremadu
Evans Enweremadu - avatar
3 Respuestas
27th Jan 2021, 7:35 AM
Evans Enweremadu
Evans Enweremadu - avatar
0
Here's my solution for python: t = input().split() hm = t[0].split(":") h = int(hm[0]) + 12 if t[1] == "PM" else hm[0] print(f"{h:0>2}:{hm[1]}") I will try your solution. And don't post repeated questions in Q/A Section.
27th Jan 2021, 7:48 AM
Ezra Bridger 2207 [INACTIVE]
Ezra Bridger 2207 [INACTIVE] - avatar
0
Alright, Thanks
27th Jan 2021, 8:51 AM
Evans Enweremadu
Evans Enweremadu - avatar