"The most wanted letter" - How to sort results?
Hi, anybody can help me. I am trying solve assignment "The most wanded letter" And stuck on it.
My code:
def checkio(text): import collections import re l=re.sub('[!@" "#$,:.]', '', text.lower()) lis=collections.Counter(l).most_common(3) return lis
My result:
for phrase: Hello World! result: "[(l, 3), (o, 2), (r, 1)]"
And I can't figure out how perform the next condition: "If you have two or more letters with the same frequency, then return the letter which comes first in the latin alphabet. For example -- "one" contains "o", "n", "e" only once for each, thus we choose "e". Anybody know how to sort this list with tuples by alphabet and quantity of appearance at the same time? How to solve the last condition? I'll be thankful for help.