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())
3 Respuestas
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.
0
Alright, Thanks