code: def countdown(template, duration=datetime.timedelta(seconds=5)):
  	
  	now = datetime.datetime.now()
  	deadline = now + duration
  	remaining = deadline - datetime.datetime.now()
  	while remaining:
  		remaining = deadline - datetime.datetime.now()
  		remaining = max(datetime.timedelta(), remaining)
  		msg = template.format(remaining.total_seconds())
  		print(msg, end=' ' * 10)
  		sys.stdout.flush()
  		time.sleep(.1)
  		print('\b' * 80, end='')
  		sys.stdout.flush()
  	print()
docs: Do a countdown for duration, printing the template (which may accept one
  	positional argument). Template should be something like
  	``countdown complete in {} seconds.``