• The Most Wanted Letter

Question related to mission The Most Wanted Letter

 

as I understand it is necessary. If the number of letters is the same, then print the letter that is the first in the alphabet. i have no idea how to fix my code

 def checkio(text: str) -> str:
    new_count = 0
    text = text.replace(' ', '')

    for i in range(len(text)):
        count = 0
        for j in range(len(text)):
            if text[i].lower() == text[j].lower() and text[i].lower() in 'qwertyuiopasdfghjklzxcvbnm':
                count += 1
                return1 = text[j].lower()
        if count >= new_count:
            new_count = count
            for_return = return1
    if new_count <= 2:
        return text[0].lower()

    return for_return


print("Example:")
print(checkio("Hello World!"))

# These "asserts" are used for self-checking
assert checkio("Hello World!") == "l"
assert checkio("How do you do?") == "o"
assert checkio("One") == "e"
assert checkio("Oops!") == "o"
assert checkio("AAaooo!!!!") == "a"
assert checkio("abe") == "a"
assert checkio('Lorem ipsum dolor sit amet') == 'm' ... ok
assert checkio('Lorem ipsum dolor sit amet 0000000000000000000') == 'm' ... ok
assert checkio('Aaaaaaaaaaaaaaaa!!!!') == 'a' ... ok
assert checkio('Gregor then turned to look out the window at the dull weather.Nooooooooooo!!! Why!?!') == 'o' ... ok
assert checkio('fn;lsfndasl;f naslkdnlkasdnfslahwemwjkrjkl;zcmk;lzcdkcslksdkseewme,') == 'k' ... Fail