0
can someone help me in solvong miltitary time
im using string slicing in solving this problem cause i want to fammiliarize slicing in python but my code doesn't pass all the test case . please guide me beginner😊 def Military(time): clock = '' if time[-2] == 'P': i = time.split(':') x = i[0] y = int(x) + 12 j = i[1] converted = j[0:2] clock = f'{y}:{converted}' else: clock = f'{time[0:5]}' return clock time = input() print(Military(time))
1 Antwort
+ 1
The problem in your code is that it won't work on two specific scenarios.
1. At 12:00 AM where the 24 hr format should be 00:00 but your code gives 12:00
2. At 12:00 PM, where the 24 hr format should be 12:00 but your code gives 24:00
Try addressing these problems in your code.