Skip to content

Instantly share code, notes, and snippets.

@amankharwal
Created August 30, 2021 06:45
Show Gist options
  • Save amankharwal/f72d45f7776ba19ce15201a0d94a1b8f to your computer and use it in GitHub Desktop.
Save amankharwal/f72d45f7776ba19ce15201a0d94a1b8f to your computer and use it in GitHub Desktop.
words = []
with open("aman.txt", "r") as f:
for line in f:
words.extend(line.split())
from collections import Counter
counts = Counter(words)
top5 = counts.most_common(5)
print(top5)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment