'Trying to fix ZeroDivisionError in game

The code below is in a 60fps pygame.time.Clock loop

f = 0
z = 180

while run:
    pygame.time.Clock.tick(60)
        
    f += 1

    if f % z == 0:
        enemy_ship = pygame.Rect(WIDTH-5,randint(0,730),SPACESHIP_WIDTH,SPACESHIP_HEIGHT)
        enemy_ships.append(enemy_ship)

        for x in range(random.randint(1,len(enemy_ships))):
            rand_ship = random.choice(enemy_ships)
            enemy_bullet = pygame.Rect(rand_ship.x,rand_ship.y,10,10)
            enemy_bullets.append(enemy_bullet)
            pygame.mixer.music.load(os.path.join('assets','enemy_shoot.wav'))
            pygame.mixer.music.play()

    if z > 0:
        z -= 1
        enemy_bullet_vel += 0.2
        #print('{}\n{}'.format(z,enemy_bullet_vel))

I'm trying to increase the speed at which the enemy ships spawn, however when z reaches 0, I get a ZeroDivisionError, how would i make it so it still spawns bullets and ships but doesn't give a ZeroDivisionError?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source