Light Mode
Dark Mode
It works... but not here
def the_most_wanted_letter(string):
    string = "".join(sorted(string.replace(" ", "").replace("!","").lower()))
    string = {x: string.count(x) for x in set(string)}
    for element in string:
        if string.get(element) == max(string.values()):
            return element

It should work, but it doesn't

UPDATE

NOW everything works fine

def the_most_wanted_letter(string):
    string = [c.lower() for c in string if c.isalpha()]
    string = {x: string.count(x) for x in sorted(string)}
    for element in string:
        if string.get(element) == max(string.values()):
            return element

P.S Not the best way to solve this task, but wanted to finish it off.

Created: April 14, 2019, 1:16 p.m.
Updated: April 15, 2019, 2:07 p.m.
2
9
User avatar
Egor_Antonov