title: Pygame, move a rectangle and remove the old rectangle in precedent position
body: <p>I'm writing this code because I want to move a rectangle using the arrow keys.
  It works, but the loop cycle doesn't move the rectangle, instead it creates a new one every time. The result is like a contrail. You can see it in the pic:<a href="https://i.stack.imgur.com/QXzZx.png" rel="nofollow noreferrer">the result of the code after some key pressure</a></p>
  
  <p>Here the code I wrote:</p>
  
  <pre><code>import sys
  import pygame
  
  pygame.init()
  pygame.display.set_caption('SAGA')
  clock=pygame.time.Clock()
  FPS=30
  #the initial position
  POS_X=300
  POS_Y=300
  ship = pygame.image.load("fighter_0.png")
  
  while True:
      #if cycle for detect the key pressure
      for event in pygame.event.get():
          if event.type == pygame.QUIT:
              pygame.quit()
              sys.exit()
          if event.type == pygame.KEYDOWN:
              if event.key ==pygame.K_UP:
                  POS_Y=POS_Y-10
          if event.type == pygame.KEYDOWN:
              if event.key ==pygame.K_DOWN:
                  POS_Y=POS_Y+10
          if event.type == pygame.KEYDOWN:
              if event.key ==pygame.K_RIGHT:
                  POS_X=POS_X+10
          if event.type == pygame.KEYDOWN:
              if event.key ==pygame.K_LEFT:
                  POS_X=POS_X-10
      #here i draw the rectangle 
      pygame.draw.rect(screen,(255,255,255),(POS_X,POS_Y,30,30))
      clock.tick(FPS)
      pygame.display.update()
  pygame.quit()
  </code></pre>
  
  <p>I think I don't understand some principle of pygame, but honestly I don't know which one.</p>