4 ms·
Nice. Just a little fixing and polishing: def top_ten(s): words = s.split() return sorted(set(words), key=words.count, reverse=True)[:10]
by abecedarius 13y ago
Nice. Just a little fixing and polishing:
def top_ten(s):
words = s.split()
return sorted(set(words), key=words.count, reverse=True)[:10]
(to get the most common words instead of the least).