I need help with a task

I’m trying to write a function that satisfies the conditions below:

Test.assert_equals(accum("ZpglnRxqenU"), "Z-Pp-Ggg-Llll-Nnnnn-Rrrrrr-Xxxxxxx-Qqqqqqqq-Eeeeeeeee-Nnnnnnnnnn-Uuuuuuuuuuu")
Test.assert_equals(accum("NyffsGeyylB"), "N-Yy-Fff-Ffff-Sssss-Gggggg-Eeeeeee-Yyyyyyyy-Yyyyyyyyy-Llllllllll-Bbbbbbbbbbb")
Test.assert_equals(accum("MjtkuBovqrU"), "M-Jj-Ttt-Kkkk-Uuuuu-Bbbbbb-Ooooooo-Vvvvvvvv-Qqqqqqqqq-Rrrrrrrrrr-Uuuuuuuuuuu")
Test.assert_equals(accum("EvidjUnokmM"), "E-Vv-Iii-Dddd-Jjjjj-Uuuuuu-Nnnnnnn-Oooooooo-Kkkkkkkkk-Mmmmmmmmmm-Mmmmmmmmmmm")
Test.assert_equals(accum("HbideVbxncC"), "H-Bb-Iii-Dddd-Eeeee-Vvvvvv-Bbbbbbb-Xxxxxxxx-Nnnnnnnnn-Cccccccccc-Ccccccccccc")

Here is what I have so far:

def accum(s):
    x = s.upper()
    my_string = ''
    for letter in x:
            my_string += letter + letter.lower() * (x.index(letter)) + '-'
        
    my_string = my_string[:-1]
    return my_string

It works until there is a duplicate letter in the input, for example:
Let’s say the input is: "nsn"

My function would output "N-Ss-N"

When it should output "N-Ss-Nnn"

Do you guys have any ideas?

the .index() will find the first occurrence, so its much more reliable to use your own counter. You could range or enumerate.

How would I access the number letter from the number? in this:
(0, a)
(1, b)
(2, c)
(3, d)
Would you have to change them to key/value pairs?

did you use enumerate for this? you could simple have two variables in the loop, one for the indexes and one for the values:

for index, item in enumerate(iterable):