title: Delay inside a while loop (Python/Pygame)
body: <p>I have this function for a death screen of a game that I am creating.  </p>
  
  <pre><code>def deathScreen():
      deathScreen = True
      while deathScreen == True:
          screen.fill(black)
          for event in pg.event.get():
              if event.type == pg.QUIT:
                  quitGame()
          deadText = titleFont.render("You Died!", True, white)
          screen.blit(deadText, (155,200))
          time.sleep(5)
          screen.fill(black)
  
  
          pg.display.flip()
          clock.tick(15)
  </code></pre>
  
  <p>I want this function to work by displaying the "deadText" variable, and then waiting 5 seconds before the screen is cleared and another piece of text to be displayed where the user will be able to enter their name. The code was initially working by displaying the "deadText" variable however ever since I added the time sleep the program just crashes with no error message at all.</p>
  
  <p>I would like to know how to get a 5 second delay and then clear the screen so U will be able to display new text.</p>