• What is wrong

Question related to mission The Most Wanted Letter

 
import string
letters = string.ascii_letters[:28]
letters2 = []


def checkio(text: str) -> str:
    text = text.lower()
    for i in text:
        if i in letters:
            letters2.append(i)
    max_letter = letters2[0]
    for i in range(1, len(letters2)):
        if letters2.count(letters2[i]) == letters2.count(max_letter):
            if letters2[i] < max_letter:
                max_letter = letters2[i]
        elif letters2.count(letters2[i]) > letters2.count(max_letter):
            max_letter = letters2[i]
    return max_letter

It works in Pycharm, but not here