Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
First solution in Clear category for The Most Wanted Letter by Patrick_vG
def checkio(text: str) -> str:
#text = text.lower()
#letters = {letter: text.count(letter) for letter in text if letter.isalpha()}
#most_freq = max(letters.values())
#return min(letter for letter, freq in letters.items() if freq == most_freq)
# Alternatively, without using a dictionary
text = "".join(filter(str.isalpha, text.lower()))
return max(sorted(text), key=text.count)
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"
print("The mission is done! Click 'Check Solution' to earn rewards!")
Sept. 23, 2023
Comments: