import math


def split(text, length):
    """Splits the text into chunks of length length, returning the list of
    chunks e.g. text='abcdefghi', length=3 -> ['abc', 'def', 'ghi']
    If the text isn't long enough, the last chunk might be shorter
    """
    chunks = []
    count = 0
    iterations = math.floor(len(text)/length)
    while count < iterations:
        chunks.append(text[length*count : length*(count+1)])
        count += 1

    #Catches the tail end which might be shorter than length
    chunks.append(text[length*count:])
    if len(chunks[-1]) > 0: #If there was some leftover
        for num in range(length-len(chunks[-1])):#pad with 'a' as necessary
            chunks[-1] += 'a'
    return(chunks)