Skip to content
Open
Changes from 1 commit
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
9 changes: 9 additions & 0 deletions HW4RonBitonPF.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
from collections import Counter
Comment thread
ronbitonn marked this conversation as resolved.
Outdated

func = open("Hallelujah.txt", "r")
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When opening file it is mandatory to close it when its no longer needed. you can use "close" method, but better implementation would be to use "with...open"

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is Better using full file path

if func.mode == 'r':
contents = func.read().split()
print(contents)

wordsCount = Counter(contents)
print(wordsCount.most_common(1))