events and before we update the screen this allows the ship' position to be updated in response to player input and ensures the updated position is used when drawing the ship to the screen when you run alien_invasion py and hold down the right arrow keythe ship should move continuously to the right until you release the key moving both left and right now that the ship can move continuously to the rightadding movement to the left is easy we'll again modify the ship class and the check_events(function here are the relevant changes to __init__(and update(in shipship py def __init__(selfscreen)--snip-movement flags self moving_right false self moving_left false def update(self)"""update the ship' position based on movement flags ""if self moving_rightself rect centerx + if self moving_leftself rect centerx - in __init__()we add self moving_left flag in update()we use two separate if blocks rather than an elif in update(to allow the ship' rect centerx value to be increased and then decreased if both arrow keys are held down this results in the ship standing still if we used elif for motion to the leftthe right arrow key would always have priority doing it this way makes the movements more accurate when switching from left to rightwhen the player might momentarily hold down both keys we have to make two adjustments to check_events()game_ functions py def check_events(ship)"""respond to keypresses and mouse events ""for event in pygame event get()--snip-elif event type =pygame keydownif event key =pygame k_rightship moving_right true elif event key =pygame k_leftship moving_left true elif event type =pygame keyupif event key =pygame k_rightship moving_right false elif event key =pygame k_leftship moving_left false