doing so much unnecessary work to do thiswe need to detect when the bottom value of bullet' rect has value of which indicates the bullet has passed off the top of the screenalien_ invasion py start the main loop for the game while truegf check_events(ai_settingsscreenshipbulletsship update(bullets update( get rid of bullets that have disappeared for bullet in bullets copy()if bullet rect bottom < bullets remove(bulletprint(len(bullets)gf update_screen(ai_settingsscreenshipbulletsyou shouldn' remove items from list or group within for loopso we have to loop over copy of the group we use the copy(method to set up the for loop uwhich enables us to modify bullets inside the loop we check each bullet to see whether it has disappeared off the top of the screen at if it haswe remove it from bullets at we insert print statement to show how many bullets currently exist in the game and verify that they're being deleted if this code works correctlywe can watch the terminal output while firing bullets and see that the number of bullets decreases to zero after each set of bullets has cleared the top of the screen after you run the game and verify that bullets are deleted properlyremove the print statement if you leave it inthe game will slow down significantly because it takes more time to write output to the terminal than it does to draw graphics to the game window limiting the number of bullets many shooting games limit the number of bullets player can have on the screen at one time to encourage players to shoot accurately we'll do the same in alien invasion firststore the number of bullets allowed in settings pysettings py bullet settings self bullet_width self bullet_height self bullet_color self bullets_allowed