'Enemy collisions on the y axis'

def check_enemy_y_collisions(self, enemy):

    collider = pg.sprite.spritecollideany(enemy, self.ground_step_pipe_group)
    brick = pg.sprite.spritecollideany(enemy, self.brick_group)
    coin_box = pg.sprite.spritecollideany(enemy, self.coin_box_group)
    if collider:
        if (enemy.rect.bottom > collider.rect.bottom):
            enemy.y_vel = 7
            enemy.rect.top = collider.rect.bottom
            enemy.state = c.FALL
        elif (enemy.rect.bottom < collider.rect.bottom):
            enemy.y_vel = 0
            enemy.rect.bottom = collider.rect.top
            enemy.state = c.WALK
    elif brick:
        if (brick.state == c.BUMPED):
            enemy.kill()
            self.sprites_about_to_die_group.add(enemy)
            if (self.mario.rect.centerx > brick.rect.centerx):
                enemy.start_death_jump('right')
            else:
                enemy.start_death_jump('left')
        elif (enemy.rect.x > brick.rect.x):
            enemy.y_vel = 7
            enemy.rect.top = brick.rect.bottom
            enemy.state = c.FALL
        else:
            enemy.y_vel = 0
            enemy.rect.bottom = brick.rect.top
            enemy.state = c.WALK
    elif coin_box:
        if (coin_box.state == c.BUMPED):
            self.game_info[c.SCORE] += 100
            self.moving_score_list.append(score.Score((enemy.rect.centerx - self.viewport.x), enemy.rect.y, 100))
            enemy.kill()
            self.sprites_about_to_die_group.add(enemy)
            if (self.mario.rect.centerx > coin_box.rect.centerx):
                enemy.start_death_jump('right')
            else:
                enemy.start_death_jump('left')
        elif (enemy.rect.x > coin_box.rect.x):
            enemy.y_vel = 7
            enemy.rect.top = coin_box.rect.bottom
            enemy.state = c.FALL
        else:
            enemy.y_vel = 0
            enemy.rect.bottom = coin_box.rect.top
            enemy.state = c.WALK
    else:
        enemy.rect.y += 1
        test_group = pg.sprite.Group(self.ground_step_pipe_group, self.coin_box_group, self.brick_group)
        if (pg.sprite.spritecollideany(enemy, test_group) is None):
            if (enemy.state != c.JUMP):
                enemy.state = c.FALL
        enemy.rect.y -= 1
