+ 4
This code is of military time(CODE COACH)..in this all tests is not completed..why it is? I m not getting it..
f=input() s=f.split(' ') if s[1]=='AM': print(s[0]) elif s[1]=="PM": z=s[0].split(':') d=int(z[0]) d=d+12 c=str(d)+":"+z[1] print(c)
5 Answers
+ 4
Please tell me what is the error in my code
+ 4
Jayakrishna thank you so much
+ 4
f=input()
s=f.split(' ')
z=s[0].split(':')
if s[1]=='AM':
if s[0]=="12:00":
print("00:00")
elif int(z[0])>9:
print(s[0])
else:
print("0"+s[0])
elif s[1]=="PM":
d=int(z[0])
d=d+12
c=str(d)+":"+z[1]
print(c)
#Now it works perfectly....
+ 2
You have the same problem as the one mentioned here:
https://www.sololearn.com/discuss/2105377/?ref=app
+ 2
For input 12:00 AM
Output should be 00:00 only
For input 12:00 PM
0utput should be 12:00 only
And also for single digit
like input 9:00 AM
Output: 09:00