Help with for loop in Drawbot Animation

Hello,

i am working on an animation in Drawbot. I wrote a function to split a letter and then said in a for loop to apply it to each letter in a string. Then I animated it to fill with another color and I want it to apply equally on each letter in the string. But how I wrote it it applys continually on each letter in the string.
How do I need to write the for loop to apply it on each letter equally?

def drawLetter(letter, number, XX,  H = H, COLOR_A = COLOR_A, COLOR_C = COLOR_C, STROKEWIDTH = STROKEWIDTH):    
    path = BezierPath()
    path.text(letter, (XX, YY), font= FONT, fontSize=fontSettings["fontSize"])
    minx, miny, maxx, maxy = path.bounds()

    w = (maxx-minx) *0.5
     
    if number == 1:    
        bottomLeft = BezierPath()
        fill(COLOR_A)
        bottomLeft.rect(minx, miny, w, H)
    elif number == 0:
        bottomLeft = BezierPath()
        fill(COLOR_A)
        bottomLeft.rect(minx+w, miny, w, H)
    
    stroke(COLOR_C)
    strokeWidth(STROKEWIDTH)
    bottomLeft = bottomLeft & path
    drawPath(bottomLeft)

H1 = 0      
for frame in range(FRAMES+1):
    newPage(CANVAS, CANVAS)
    fill(0)
    rect(0, 0, CANVAS, CANVAS)
    frameDuration(1 / 24)
    fontSize(fontSettings["fontSize"])
    font(FONT)
    for letter in txt: 
        letterWidth, letterHeight = textSize(letter)
        drawLetter(letter, 1, XX=XX, H = h, COLOR_A = COLOR_A, COLOR_C = COLOR_A, STROKEWIDTH = STROKEWIDTH)
        drawLetter(letter, 0, XX=XX, H = h, COLOR_A = COLOR_A, COLOR_C = COLOR_A, STROKEWIDTH = STROKEWIDTH)
        if H1 <= H:
            drawLetter(letter, 1, XX=XX, H = H1, COLOR_A = COLOR_B, COLOR_C = COLOR_B, STROKEWIDTH = STROKEWIDTH_2)
            H1 += STEP
            drawLetter(letter, 0, XX=XX, H = H2, COLOR_A = COLOR_B, COLOR_C = COLOR_B, STROKEWIDTH = STROKEWIDTH_2)
            H2 -= STEP
        translate(letterWidth, 0)

Thats how it looks right now:
HHH

and they should actually be on the same height.

Sorry if I formulated the question too complicated. Thats my first post.