Skip to content

Instantly share code, notes, and snippets.

@mesiriak
Created April 15, 2021 19:17
Show Gist options
  • Save mesiriak/230b7c55f57da202b43007dfc7874a8f to your computer and use it in GitHub Desktop.
Save mesiriak/230b7c55f57da202b43007dfc7874a8f to your computer and use it in GitHub Desktop.
Codewars. Python
import collections
import re
def top_3_words(text):
c = collections.Counter(re.findall(r"[a-z']*[a-z]+[a-z']*", text.lower()))
return [i[0] for i in c.most_common(3)]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment