title: Python for beginners
body: <p>Python programming: I need to write a program that takes two inputs of military time. For example,(0900,1700) and output the time differences of the two input in numbers in hours, minutes </p>
  
  <p>ex:</p>
  
  <pre><code>print("Enter the first time:") 0900
  print("Enter the second time:") 1730
  </code></pre>
  
  <p>output</p>
  
  <pre><code>8 hours 30 minutes
  </code></pre>
  
  <p>And in the reverse order</p>
  
  <pre><code>print("Enter the second time:") 1730
  print("Enter the first time:") 0900
  </code></pre>
  
  <p>output</p>
  
  <pre><code>15 hours 30 minutes
  </code></pre>
  
  <p>I have tried the code below, but the output was just my input.</p>
  
  <pre><code>import datetime,time
  
  first = input("Enter the first time in military hours:")
  second = input( "Enter the second time in military hours:")
  first_t= datetime.time(hour=int(first[0:2]), minute=int(first[2:4]))
  second_t= datetime.time(hour=int(second[0:2]), minute=int(second[2:4]))
  hour = ( second.hour-first.hour )
  minute= (second.hour-first.hour)
  fmt = ("%H ,%M")
  print (first_t.strftime(fmt) , second_t.strftime(fmt))
  </code></pre>
  
  <p>For the input values <code>0500,1830</code>, it gave me the output of <code>05 , 00 18 , 30</code></p>