3/5 tests failed. Why? Thank Everyone. I solved this here's the working code. | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 2

3/5 tests failed. Why? Thank Everyone. I solved this here's the working code.

https://code.sololearn.com/cRac9Oi8j7mv/?ref=app

11th May 2020, 1:23 AM
amir amiri
2 Answers
+ 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))
11th May 2020, 1:28 AM
Abhay
Abhay - avatar
+ 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
11th May 2020, 1:30 AM
ChaoticDawg
ChaoticDawg - avatar