Created
March 12, 2019 21:49
-
-
Save CaioEuzebio/ce3603bb9535887cc91e44aa236e8586 to your computer and use it in GitHub Desktop.
Word Count
This file contains 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
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