title: Ship won't stop moving left in python crash course alien invasion
body: <p>I'm practicing python in python crash course and I am doing the first project which is alien invasion.
  I'm still in the beginning of it in the part where you start to move the ship left to right and on keydown and keyup for the right key it works fine. For the left key it just keeps moving left and will not stop moving. I have written exactly what the books as said to write and i have looked on here and on google to see if anyone one else has had this error as well but can't seem to find anything that can help me.</p>
  <p>alien_invasion.py</p>
  <pre><code>import pygame
  from settings import Settings
  from ship import Ship
  import game_functions as gf
  
  def run_game():
    # Initialize game and create a screen object.
    pygame.init()
    ai_settings = Settings()
    screen = pygame.display.set_mode(
      (ai_settings.screen_width, ai_settings.screen_height))
    pygame.display.set_caption(&quot;Alien Invasion&quot;)
  
  
   # Make a ship
   ship = Ship(screen)
   
   # Start the main loop for the game.
   while True:
      gf.check_events(ship)
      ship.update()
      gf.update_screen(ai_settings, screen, ship)
     
     
  run_game()
  </code></pre>
  <p>game_functions.py</p>
  <pre><code> import sys
   import pygame
  
  
   def check_events(ship):
      &quot;&quot;&quot;Respond to keypresses and mouse events&quot;&quot;&quot;
      for event in pygame.event.get():
         if event.type == pygame.QUIT:
             sys.exit()
         elif event.type == pygame.KEYDOWN:
             if event.key == pygame.K_RIGHT:
               ship.moving_right = True
             elif event.key == pygame.K_LEFT:
                ship.moving_left = True
         elif event.type == pygame.KEYUP:
             if event.key == pygame.K_RIGHT:
               ship.moving_right = False
             elif event.key == pygame.K_LEFT:
               ship.moving_left == False
  
   def update_screen(ai_settings, screen, ship):
     &quot;&quot;&quot;Update images on the screen and flip to the new screen.&quot;&quot;&quot;
     # Redraw the screen during each pass through the loop.
     screen.fill(ai_settings.bg_color)
     ship.blitme()
              
     # make the most recently drawn screen visible.
     pygame.display.flip()
  </code></pre>
  <p>ship.py
  import pygame</p>
  <pre><code>class Ship():
    def __init__(self, screen):
       &quot;&quot;&quot;Initialize the ship and set its starting position.&quot;&quot;&quot;
       self.screen = screen
      
       # Load the ship image and get its rect.
       self.image = pygame.image.load('img/ship.bmp')
       self.rect = self.image.get_rect()
       self.screen_rect = screen.get_rect()
      
       # Start each new ship at the bottom center of the screen.
       self.rect.centerx = self.screen_rect.centerx
       self.rect.bottom = self.screen_rect.bottom
      
       # Movement flags
       self.moving_right = False
       self.moving_left = False
      
    def update(self):
       &quot;&quot;&quot;Update the ships's position based on the movement flag&quot;&quot;&quot;
       if self.moving_right:
           self.rect.centerx += 1
       if self.moving_left:
          self.rect.centerx -= 1
      
   def blitme(self):
       &quot;&quot;&quot;Draw the ship at its current location&quot;&quot;&quot;
       self.screen.blit(self.image, self.rect)
      
  </code></pre>