Skip to content

Instantly share code, notes, and snippets.

@dionimf
Forked from fmasanori/Word Count.py
Last active August 29, 2015 14:06
Show Gist options
  • Save dionimf/28c71342c707cfa6442b to your computer and use it in GitHub Desktop.
Save dionimf/28c71342c707cfa6442b to your computer and use it in GitHub Desktop.
arq = open('alice.txt')
texto = arq.read()
texto = texto.lower()
import string
for c in string.punctuation:
texto = texto.replace(c, ' ')
texto = texto.split()
dic = {}
for p in texto:
if p not in dic:
dic[p] = 1
else:
dic[p] += 1
print ('Alice aparece %s vezes' %dic['alice'])
arq.close()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment