title: How to create a "play again" option with Pygame
body: <p>I am new to programming with Python. I have been working through a tutorial book that I found, and got the game up and running, but then decided I wanted to have a "Play Again?" option at the end. I can get the game to quit out with a press of the "n" key, but cannot work out how to get the game to restart.</p>
  
  <p>Here is the code I think is giving the trouble:</p>
  
  <pre><code>#player reaches treasure
  if player_rectangle.colliderect(treasure_rectangle):
  
  #display text
      screen.blit(text,(screen_width/2-195,screen_height/2-25))
      if event.type==pygame.KEYDOWN:
          if event.key==pygame.K_n:
              exit()
  
      elif event.key==pygame.K_y:
  
  
  pygame.display.update()
  </code></pre>
  
  <p>I know something needs to go after the elif event, and I have tried all that I can think of. I tried to define the whole program, and call it but that stopped the whole thing running. I have looked around internet sites, but just cannot seem to come up with a answer. </p>
  
  <p>Can some one help out in easy terms how to get the game to restart to the starting position when the y key is pressed? I know it has something to do with a loop, I just cannot place my finger on what.</p>
  
  <p>Many thanks.</p>