Created
February 24, 2017 09:10
-
-
Save walkingmask/ab0ab10438bc6f8b986774c13b5442a1 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
#!/usr/bin/env python3 | |
# -*- coding: utf-8 -*- | |
import sys | |
from collections import defaultdict | |
def count_words(file_name): | |
file_open = open(file_name, 'r') | |
my_dict = defaultdict(int) | |
for line in file_open: | |
words = line.strip().split(" ") | |
for word in words: | |
my_dict[word] += 1 | |
return my_dict | |
if __name__ == '__main__': | |
count_words(sys.argv[1]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment