get coordinates of insertions from insertion-masked sequence

def insertions_from_masked(seq):
    """
    get coordinates of insertions from insertion-masked sequence
    """
    insertions = []
    prev = True
    for i, base in enumerate(seq):
        if base.isupper() and prev is True:
            insertions.append([])
            prev = False
        elif base.islower():
            insertions[-1].append(i)
            prev = True
    return [[min(i), max(i)] for i in insertions if i != []]