def checkio(text: str) -> str:
import re
letter = []
text = text.lower()
for c in text:
m = re.match(r'[a-z]', c)
if m is None:
continue
else:
letter.append(c)
list_zero = []
set_letter = set(letter)
length = len(set_letter)
for _ in range(length):
list_zero.append(0)
list_letter = list(set_letter)
letter_dict = dict(zip(list_letter, list_zero))
for c in letter:
letter_dict[c] = letter_dict[c] + 1
dict_sorted = sorted(letter_dict.items(), key=lambda x: (-x[1], x[0]))
return dict_sorted[0][0]
if __name__ == '__main__':
print("Example:")
print(checkio("Hello World!"))
assert checkio("Hello World!") == "l", "Hello test"
assert checkio("How do you do?") == "o", "O is most wanted"
assert checkio("One") == "e", "All letter only once."
assert checkio("Oops!") == "o", "Don't forget about lower case."
assert checkio("AAaooo!!!!") == "a", "Only letters."
assert checkio("abe") == "a", "The First."
print("Start the long test")
assert checkio("a" * 9000 + "b" * 1000) == "a", "Long."
print("The local tests are done.")