def splitIntoGroupsOf(groupSize, theList):
    """ splits a list into list of lists,
    where the inner lists have at most
    groupSize number of items.
    """
    result = []
    for i in range(0, len(theList), groupSize):
        result.append(theList[i:i + groupSize])
    return result