title: Python3: Continuously update datetime value from inside while loop
body: <p>I'm having trouble with the code below which is asking the user to enter a 'wakeup' time, which the python script will then use to calculate how long until the clock reaches zero. From what I have below, I think that I need to place the <code>tdelta</code> calculation inside the while loop so that it constantly checks for the <strong>current</strong> time. </p>
  
  <p>At the moment, It seems that <code>tdelta</code> will check for the current time in seconds and then use that same value to run through the while loop. Therefore never ending because it uses the same time over and over again. Should I be using a <strong>function</strong> inside of the while loop to continuously check for the new value and then evaluate true or false?</p>
  
  <pre><code>from datetime import datetime
  import time
  now = datetime.now()
  hms = "%s:%s:%s" % (now.hour, now.minute, now.second)
  
  ans = input('Enter hour:minute:seconds')
  
  s1 = hms
  s2 = ans # for example
  FMT = '%H:%M:%S'
  tdelta = datetime.strptime(s2, FMT) - datetime.strptime(s1, FMT)
  
  if tdelta.days &lt; 0:
      tdelta = timedelta(days=0,
                  seconds=tdelta.seconds, microseconds=tdelta.microseconds)
  
  
  while tdelta.seconds != 0:
      # Use this to see what is happening inside the loop. Here it continuously prints the same time in seconds so is a continuous loop. I need to somehow update the tdelta time.
      if tdelta.seconds != 0:
          print(tdelta.seconds)
          time.sleep(1)
  
      else:
          print('time up...do something')
  </code></pre>
  
  <p>I've tried dozens of variations of the code above but with no luck. I appreciate any tips. Thanks. </p>