def splitKeep(s, delim):
    """
    Similar to split, but keeps the delimiter as separate element, e.g.
    splitKeep("aaabaaabaa", "b") -> ["aaa", "b", "aaa", "b", "aa"]
    """
    result = []
    for e in s.split(delim):
        result.append(e)
        result.append(delim)

    return result[:-1]