diff --git a/count_word.py b/count_word.py index e69de29..354c983 100644 --- a/count_word.py +++ b/count_word.py @@ -0,0 +1,11 @@ + + +def countWord(filepath='files/testfile.txt', word='dummy'): + f = open(filepath) + cnt = 0 + for line in f: + if word in line: + cnt+=1 + return cnt + +print countWord('files/testfile.txt','Lorem') diff --git a/count_word.pyc b/count_word.pyc new file mode 100644 index 0000000..486f72b Binary files /dev/null and b/count_word.pyc differ diff --git a/files/testfile.txt b/files/testfile.txt index 9624122..204dad2 100644 --- a/files/testfile.txt +++ b/files/testfile.txt @@ -1,2 +1,2 @@ -Lorem Ipsum is simply dummy text of the printing and typesetting industry. -Lorem Ipsum has been the industry's standard dummy text ever since the 1500s. \ No newline at end of file +Lorem Ipsum is simply dummy text of the printing and typesetting industry. +Lorem Ipsum has been the industry's standard dummy text ever since the 1500s. diff --git a/tests/__init__.pyc b/tests/__init__.pyc new file mode 100644 index 0000000..57e8a0a Binary files /dev/null and b/tests/__init__.pyc differ diff --git a/tests/test_countWord.pyc b/tests/test_countWord.pyc new file mode 100644 index 0000000..3ff816f Binary files /dev/null and b/tests/test_countWord.pyc differ