def get_gender_lines_by_scene(gender_to_gender, act_scene_start_end):
    """ for each scene in play, get the range of lines in female_to_female
    which belong to that scene. As is in common, the range is defined to be
    (inclusive, exclusive).

    For example:
    if 
    >>> gender_to_gender = [0, 1, 3, 8, 9, 10, 11, 100, 101]
    >>> act_scene_start_end = [(0, 10), (10, 30), (30, 80), (80, 102)]

    then after 
    >>> gender_lines_by_scene = [ lines_by_scene(gender_to_gender, end) for _ ,
            end in act_scene_start_end ]
    >>> gender_lines_by_scene == [(0, 5), (5, 7), (7,7), (7,9)]
    """
    class LinesByScenes:
        def __init__(self):
            self.left_marker = 0
            self.reached_end = False

        def __call__(self, gender_to_gender, end):
            if self.reached_end:
                return (len(gender_to_gender), len(gender_to_gender))
            for i in range(self.left_marker, len(gender_to_gender)):
                line_n = gender_to_gender[i]
                if line_n >= end:
                    line_range = (self.left_marker, i)
                    self.left_marker = i
                    return line_range
            self.reached_end = True
            return (self.left_marker, len(gender_to_gender))

    lines_by_scene = LinesByScenes()
    gender_lines_by_scene = [ lines_by_scene(gender_to_gender, end) for _ ,
            end in act_scene_start_end ]
    return gender_lines_by_scene