Skip to content

Instantly share code, notes, and snippets.

@CaioEuzebio
Created March 12, 2019 21:49
Show Gist options
  • Save CaioEuzebio/ce3603bb9535887cc91e44aa236e8586 to your computer and use it in GitHub Desktop.
Save CaioEuzebio/ce3603bb9535887cc91e44aa236e8586 to your computer and use it in GitHub Desktop.
Word Count
file = open('filetext.txt')
text = file.read()
text = text.lower()
import string
for c in string.punctuation:
text = text.replace(c, ' ')
text = text.split()
d = {}
for p in text:
if p not in d:
d[p] = 1
else:
d[p] += 1
print("Times that %s word repeats: " %d['word'])
file.close()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment