Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions count_word.py
Original file line number Diff line number Diff line change
@@ -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')
Binary file added count_word.pyc
Binary file not shown.
4 changes: 2 additions & 2 deletions files/testfile.txt
Original file line number Diff line number Diff line change
@@ -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.
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.
Binary file added tests/__init__.pyc
Binary file not shown.
Binary file added tests/test_countWord.pyc
Binary file not shown.