Created
August 21, 2019 03:05
-
-
Save dmoneyballer/dabb75b9471d5d4acd03f20d2e6041c0 to your computer and use it in GitHub Desktop.
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
# Put your code here | |
from collections import OrderedDict | |
with open('test.txt', 'w') as e: | |
e.write("""I DO NOT LIKE THEM IN A HOUSE | |
I DO NOT LIKE THEM WITH A MOUSE | |
I DO NOT LIKE THEM HERE OR THERE | |
I DO NOT LIKE THEM ANYWHERE | |
I DO NOT LIKE GREEN EGGS AND HAM | |
I DO NOT LIKE THEM SAM I AM """) | |
start = input('Enter the input file name:') | |
words = OrderedDict() | |
with open(start, 'r') as f: | |
for line in f: | |
wordz = line.split() | |
for word in wordz: | |
if word in words.keys(): | |
words[word] = words[word] + 1 | |
else: | |
words[word] = 1 | |
for w, c in words.items(): | |
print(w, c) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment