Skip to content

Instantly share code, notes, and snippets.

@voyeg3r
Forked from fmasanori/Word Count.py
Created January 25, 2017 21:13
Show Gist options
  • Save voyeg3r/25247763865f0cd7b5a12691fe94c222 to your computer and use it in GitHub Desktop.
Save voyeg3r/25247763865f0cd7b5a12691fe94c222 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