diff --git a/count_word.py b/count_word.py index e69de29..e5f582f 100644 --- a/count_word.py +++ b/count_word.py @@ -0,0 +1,12 @@ +def countWord(fname,word): + count = 0 + with open(fname, 'r') as f: + for line in f: + words = line.split() + for i in words: + lower_case = i.replace(".","") + if(lower_case == word): + count=count+1 + return count + +# countWord('testfile.txt','dummy') diff --git a/count_word.pyc b/count_word.pyc new file mode 100644 index 0000000..e4b5ed2 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..9eb472c 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..162f4d1 Binary files /dev/null and b/tests/test_countWord.pyc differ