• Need Help

Question related to mission The Most Wanted Letter

 

Having trouble with this. It keeps stating that my string index is out of range and I dunno how to fix that.

def checkio(text: str) -> str:

    #replace this for solution
    alphabet = 'abcdefghijklmnopqrstuvwxyz'
    text = text.lower()
    dct = {}
    for letter in text:
        if letter in alphabet:
            number = text.count(letter)
            dct[letter] = number
    maximum = sorted(dct, key=lambda x:(x[1], -x[0]))
    return maximum[0][0]