title: How to change a variable in an if statement and have it stay as the number assigned in the statement outside of the statement?
body: <p>I want a red rectangle that is drawn in my main loop to be able to move to the left along the x axis. (I am using a pygame if statement for the keyboard controls). The rectangle only goes to the left by 50 when the left arrow key is pressed (which is fine) but then when the left key isn't being pressed it goes back to its original position.</p>
  
  <p>So basically I want to be able to change x in the keyboard controls if statement and for it to stay as the edited number outside the if statement.</p>
  
  <pre><code>x = 500
  y = 500
  
  screen.fill(WHITE)
  
  if event.type == pygame.KEYDOWN: 
      if event.key == pygame.K_LEFT:
         x -= 50      
  
  pygame.draw.rect(screen, RED, (x,y,300,300), 0);`
  </code></pre>