+ 1
What is wrong with this code? Code coach challange,. Military time challange
It is a military time challange. This code gives first 2 test cases correct and other as failed. import datetime def timeconvert(str1): if str1[-2:]== "AM" and str1[:2] =="12": return "00" + str1[2:-2] elif str1[-2:] == "AM": return str1[:-2] elif str1[-2:]== "PM" and str1[:2]=="12": return str1[:-2] else: return str(int(str1[0:2])+12)+str1[2:5] da=input() print(timeconvert(da)) https://code.sololearn.com/cA9l3sj0Bi3V/?ref=app https://code.sololearn.com/cA9l3sj0Bi3V/?ref=app
2 ответов
+ 1
Thank you Dennis i got it🙂
0
The output should be in XX:XX format.
Your code does not follow this rule.
For example, your code prints "5:00", whose format is X:XX, for the input "5:00 AM" to get it correct it should be "05:00".