def segment_generator(List, segment_size):
    """ Split a list into s segments of size r (segment_size).

        Parameters
        ----------
        List: list
            List of items to be segmented.
        segment_size: int
            Size of each segment.

        Returns
        -------
        Generator
    """
    for i in range(0, len(List), segment_size):
        yield List[i:i + segment_size]
