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 at: 2019/04/14 13:16; Updated at: 2019/04/15 14:07
The question is resolved.