+ 2
3/5 tests failed. Why? Thank Everyone. I solved this here's the working code.
3 Respostas
+ 3
def MT(time):
hrs = 0
mins = 0
if time[2] == ':':
hrs = int(time[0])*10+int(time[1])
mins = int(time[3])*10+int(time[4])
else:
hrs = int(time[0])
mins = int(time[2])*10+int(time[3])
if 'P' in time:
hrs += 12
if hrs <10:
hrs=str("0")+str(hrs)
if mins < 10:
mins = str("0")+str(mins)
mt = str(hrs)+':'+str(mins)
return mt
#for i in range(1, 13):
#for j in range()
US = input("")
print(MT(US))
+ 3
time = str(input())
b = int(time[:2])
This is wrong. First input is already a string so str() isn't needed. Next, check what b is when the given time is:
1:30 AM = '1:'
This results in an error. Also, check the output for the same given time once you fix that issue. Should be
01:30 not 1:30