[Solved] Why the image in pygame doesn’t remove but stops moving?

lukmik Asks: Why the image in pygame doesn’t remove but stops moving?
I’m making an exercise from python crash course book and I want raindrops to dissapear(remove) after they hit the bottom of the screen. Instead of dissapearing they stop moving. When I write the same code (the removing part) in other similar project it works. This is the part of the code that is not working like I want it to.

Code:
import pygame
from settings import Settings
import sys
from raindrop import Image
from pygame.sprite import Sprite


class Raindrop(Sprite):

    def __init__(self):
        
        # Initialize pygame and create screen
        pygame.init()
        self.settings = Settings()
        self.screen = pygame.display.set_mode(
            [self.settings.screen_width, self.settings.screen_height])
        self.screen.fill(self.settings.bg)

        # Create group of raindrops
        self.raindrop = Image(self)
        self.raindrops = pygame.sprite.Group()
        self.raindrops.add(self.raindrop)
        self.row_of_raindrops()

    def run_game(self):
        
        while True:
            self.not_quit()
            self._update_raindrop()
            self.update_screen()

            for drop in self.raindrops.copy():
                if drop.rect.bottom >= 750:
                    self.raindrops.remove(drop)

    def not_quit(self):
        # Not close the pygame window
        for event in pygame.event.get():
            if event.type == pygame.QUIT or (
                event.type == pygame.KEYDOWN and event.key == pygame.K_q):
                sys.exit()

    def row_of_raindrops(self):
        raindrop = Image(self)
        raindrop_width, raindrop_height = raindrop.rect.size
        width_for_raidnrops = self.settings.screen_width - (2 * raindrop_width)
        range_for_raindrops = width_for_raidnrops // (2 * raindrop_width)
        raindrop_width, raindrop_height = raindrop.rect.size
        height_for_raindrops = self.settings.screen_height - (3 * raindrop_height)
        range_height_for_raindrops = height_for_raindrops // (2 * raindrop_height)
        for raindrop_number in range(range_for_raindrops):
            for column_numbers in range(range_height_for_raindrops):
                raindrop = Image(self)
                raindrop.x = raindrop_width + 2 * raindrop_width * raindrop_number
                raindrop.rect.x = raindrop.x
                raindrop.y = raindrop_height + 2 * raindrop_height * column_numbers
                raindrop.rect.y = raindrop.y
                self.raindrops.add(raindrop)
    
    def _update_raindrop(self):
        self.raindrops.update()


    def update_screen(self):
        self.raindrops.draw(self.screen)
        pygame.display.flip()

if __name__ == "__main__":
    x = Raindrop()
    x.run_game()



import pygame
from pygame.sprite import Sprite

class Image(Sprite):

    def __init__(self, x_game):
        super().__init__()
        
        self.screen = x_game.screen
        self.settings = x_game.settings

        # Load image and get it rect
        self.image = pygame.image.load("C:/Users/lukas/Desktop/python/raindrops/raindrop.jpg")
        self.image = pygame.transform.scale(self.image, (50, 50))
        self.rect = self.image.get_rect()

        # Raindrop position
        self.rect.x = self.rect.width
        self.rect.y = self.rect.height

        self.y = float(self.rect.y)

    def update(self):
        self.y += self.settings.raindrop_speed
        self.rect.y = self.y

Ten-tools.com may not be responsible for the answers or solutions given to any question asked by the users. All Answers or responses are user generated answers and we do not have proof of its validity or correctness. Please vote for the answer that helped you in order to help others find out which is the most helpful answer. Questions labeled as solved may be solved or may not be solved depending on the type of question and the date posted for some posts may be scheduled to be deleted periodically. Do not hesitate to share your response here to help other visitors like you. Thank you, Ten-tools.