Skip to content

Instantly share code, notes, and snippets.

@fmasanori
Last active September 6, 2022 12:05
Show Gist options
  • Save fmasanori/4673017 to your computer and use it in GitHub Desktop.
Save fmasanori/4673017 to your computer and use it in GitHub Desktop.
texto = open('alice.txt').read().lower()
from string import punctuation
for c in 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 (f'{dic["alice"]} vezes')
@marcelo-reis
Copy link

Fabiovilela, tenta adicionar o "encoding" no open:
file = open(filename, encoding="utf8")

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment