-
-
Save voyeg3r/25247763865f0cd7b5a12691fe94c222 to your computer and use it in GitHub Desktop.
Word Count, please download http://www.gutenberg.org/cache/epub/11/pg11.txt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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