in game_functions py to check how many bullets exist before creating new bullet in check_keydown_events()game_ functions py def check_keydown_events(eventai_settingsscreenshipbullets)--snip-elif event key =pygame k_spacecreate new bullet and add it to the bullets group if len(bulletsai_settings bullets_allowednew_bullet bullet(ai_settingsscreenshipbullets add(new_bulletwhen the spacebar is pressedwe check the length of bullets if len(bulletsis less than threewe create new bullet but if three bullets are already activenothing happens when the spacebar is pressed if you run the game nowyou should be able to fire bullets only in groups of three creating the update_bullets(function we want to keep our main alien_invasion py program file as simple as possibleso now that we've written and checked the bullet management code we can move it to the game_functions module we'll create new function called update_bullets(and add it to the end of game_functions pygame_ functions py def update_bullets(bullets)"""update position of bullets and get rid of old bullets ""update bullet positions bullets update(get rid of bullets that have disappeared for bullet in bullets copy()if bullet rect bottom < bullets remove(bulletthe code for update_bullets(is cut and pasted from alien_invasion pythe only parameter it needs is the group bullets the while loop in alien_invasion py looks simple againalien_ invasion py start the main loop for the game while truegf check_events(ai_settingsscreenshipbulletsship update(gf update_bullets(bulletsgf update_screen(ai_settingsscreenshipbulletswe've made it so that our main loop contains only minimal code so we can quickly read the function names and understand what' happening in the game the main loop checks for player input at uand then it updates the position of the ship at and any bullets that have been fired at we then use the updated positions to draw new screen at ship that fires bullets