title: Converting time from AM/PM format to military time in Python
body: <p>Without using any libraries, I'm trying to solve the Hackerrank problem "<a href="https://www.hackerrank.com/challenges/time-conversion?h_r=next-challenge&amp;h_v=zen" rel="noreferrer">Time Conversion</a>", the problem statement of which is copied below.</p>
  
  <p><a href="https://i.stack.imgur.com/YRr6p.png" rel="noreferrer"><img src="https://i.stack.imgur.com/YRr6p.png" alt="enter image description here"></a></p>
  
  <p>I came up with the following:</p>
  
  <pre><code>time = raw_input().strip()
  
  meridian = time[-2:]        # "AM" or "PM"
  time_without_meridian = time[:-2]
  hour = int(time[:2])
  
  if meridian == "AM":
      hour = (hour+1) % 12 - 1
      print ("%02d" % hour) + time_without_meridian[2:]
  elif meridian == "PM":
      hour += 12
      print str(hour) + time_without_meridian[2:]
  </code></pre>
  
  <p>However, this fails on one test case:</p>
  
  <p><a href="https://i.stack.imgur.com/yQLb9.png" rel="noreferrer"><img src="https://i.stack.imgur.com/yQLb9.png" alt="enter image description here"></a></p>
  
  <p>Since the test cases are hidden to the user, however, I'm struggling to see where the problem is occurring. "12:00:00AM" is correctly converted to "00:00:00", and "01:00:00AM" to "01:00:00" (with the padded zero). What could be wrong with this implementation?</p>