Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
takewhile(most_common) solution in Clear category for Most Wanted Letter by flpo
from collections import Counter
from itertools import takewhile
from string import ascii_letters as letters
def most_wanted(text: str) -> str:
counter = Counter(c.lower() for c in text if c in letters)
(mc0, _max), *mc = counter.most_common()
return [mc0] + [e for e, _ in takewhile(lambda x: x[1] == _max, mc)]
Aug. 20, 2018
Comments: