title: How do I make a count down timer to run alongside my game in python?
body: <p>I'm fairly new to Python and have created a trivia quiz, linking to txt files for the questions / answers and to store the high scores.</p>
  
  <p><strong>EDIT</strong> I AM NOT USING PYGAME</p>
  
  <p>I would like to set a time limit for the questions to be answered, for example 1 minute. I've managed to get the timer to countdown but it counts down and then proceeds to my game. </p>
  
  <p>Is there a way to make it run alongside? I thought about a while loop but it just messed it up so I'm guessing I did it wrong...</p>
  
  <p>Here's my code (well the top bit):</p>
  
  <pre><code>import linecache
  import sys
  import pickle
  import time
  
  def countdown():
      t = 60
      while t:
          mins, secs = divmod(t, 60)
          timeformat = '{:02d}:{:02d}'.format(mins, secs)
          print(timeformat, end='\r')
          time.sleep(1)
          t -= 1
      print('You're out of time!\n')
  
  def travel():
      i = 0
      countdown()
      name = input("What is your name: ")
      q1 = linecache.getline("travel.txt", 1)
      a1 = linecache.getline("travel.txt", 2)
      b1 = linecache.getline("travel.txt", 3)
      c1 = linecache.getline("travel.txt", 4)
      print("\n", q1, a1, b1, c1)
      q = input("Answer: ")
      if q == "b":
          print("Correct! You've scored 1 point.")
          i += 1
      else:
          print("Wrong answer buddy, 0 points.")
  </code></pre>