Test case 4 is not working for military time code coach problem [SOLVED] | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Test case 4 is not working for military time code coach problem [SOLVED]

Here is my code: OldDate = input() def converT(text): if text[5] == 'A': return '0'+text[:5] elif text[5] == 'P': if text[0]== '1': return "13"+text[1:4] elif text[0]== '2': return "14"+text[1:4] elif text[0]== '3': return "15"+text[1:4] elif text[0]== '4': return "16"+text[1:4] elif text[0]== '5': return "17"+text[1:4] elif text[0]== '6': return "18"+text[1:4] elif text[0]== '7': return "19"+text[1:4] elif text[0]== '8': return "20"+text[1:4] elif text[0]== '9': return "21"+text[1:4] elif text[6] == 'A': if text[1]=='2': return "00"+text[2:5] else: return text[:5] else: if text[1]=='0': return "22"+text[2:5

10th Sep 2021, 9:42 AM
Melek
Melek - avatar
2 Answers
+ 1
Hi Melek! It gives wrong output if input starts with 0 and ends with PM. I mean 09:45 PM is equal to 21:45 but your solution doesn't print a correct format. For that, you can add this snippet in your else part. else: return str(int(text[:2])+12)+text[2:5]
10th Sep 2021, 11:00 AM
Python Learner
Python Learner - avatar
+ 1
Thanks Python Learner! I didn't know the input was also in a XX:XX format
10th Sep 2021, 11:30 AM
Melek
Melek - avatar