at this point the ship will disappear off either edge of the screen if you hold down an arrow key long enough let' correct this so the ship stops moving when it reaches the edge of the screen we do this by modifying the update(method in shipship py def update(self)"""update the ship' position based on movement flags ""update the ship' center valuenot the rect if self moving_right and self rect right self screen_rect rightself center +self ai_settings ship_speed_factor if self moving_left and self rect left self center -self ai_settings ship_speed_factor update rect object from self center self rect centerx self center this code checks the position of the ship before changing the value of self center the code self rect right returns the -coordinate value of the right edge of the ship' rect if this value is less than the value returned by self screen_rect rightthe ship hasn' reached the right edge of the screen the same goes for the left edgeif the value of the left side of the rect is greater than zerothe ship hasn' reached the left edge of the screen this ensures the ship is within these bounds before adjusting the value of self center if you run alien_invasion py nowthe ship should stop moving at either edge of the screen refactoring check_events(the check_events(function will increase in length as we continue to develop the gameso let' break check_events(into two more functionsone that handles keydown events and another that handles keyup eventsgame_ functions py def check_keydown_events(eventship)"""respond to keypresses ""if event key =pygame k_rightship moving_right true elif event key =pygame k_leftship moving_left true def check_keyup_events(eventship)"""respond to key releases ""if event key =pygame k_rightship moving_right false elif event key =pygame k_leftship moving_left false ship that fires bullets