Skip to content

Instantly share code, notes, and snippets.

@walkingmask
Created February 24, 2017 09:10
Show Gist options
  • Save walkingmask/ab0ab10438bc6f8b986774c13b5442a1 to your computer and use it in GitHub Desktop.
Save walkingmask/ab0ab10438bc6f8b986774c13b5442a1 to your computer and use it in GitHub Desktop.
#!/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