title: Python - Ending Time with 24 hour clock logic with leading zeros
body: <p>I'm working on <a href="http://cscircles.cemc.uwaterloo.ca/8-remix/#pybox8" rel="nofollow">this intro to python online course</a>. I am close to a solution to this problem which reads:</p>
  
  <blockquote>
    <p>This program takes two lines of input. The first line is a "starting time" expressed in a 24-hour clock with leading zeroes, like 08:30 or 14:07. The second line is a duration D in minutes. Print out what time it will be D minutes after the starting time. For example, for input</p>
  </blockquote>
  
  <pre><code>12:30
  47
  </code></pre>
  
  <p>Output:</p>
  
  <pre><code>13:17
  </code></pre>
  
  <p>Hints given:</p>
  
  <pre><code>Break the input into hours and minutes.
  Final minutes should be (M + D) % 60.
  Final hours requires //60 and % 24.
  </code></pre>
  
  <p>My solution so far:</p>
  
  <pre><code>ST = input()
  STlen = len(ST)
  D = int(input())
  
  for position in range (0,STlen):
     if ST[position] == ':':
        H = int(ST[0:position])
        M = int(ST[position+1:STlen])
  
  #minutes section
  final_min = (M+D) % 60
  if final_min &lt; 10:
     finalminstr1 = str(final_min)
     zeroed_finalmin_str = '0' + finalminstr1
     final_min = zeroed_finalmin_str
  else:
     final_min = (M+D) % 60
  
  #hours section
  if D &gt; 60:
     finalhr = (D // 60) + H
  elif (M+D) % 60 &gt; 0 and H % 24 == H and D &lt; 60:
     finalhr = H+1
  if finalhr == 24:
     finalhr = '00'
  
  #getting final end time ready
  finalminstr = str(final_min)
  finalhrstr = str(finalhr)
  endtime = finalhrstr + ":" + finalminstr
  print(endtime)
  </code></pre>
  
  <p>I think my approach is too convoluted and would waste processing time. It's also breaking when I use</p>
  
  <pre><code>15:33
  508
  </code></pre>
  
  <p>as input data. The correct output should be 00:01, but I'm getting 23:01.</p>
  
  <p>Any ideas on how to improve my code? <strong>Also, please do not use functions or methods.</strong> We haven't learned how to use functions or methods yet!</p>