-
Notifications
You must be signed in to change notification settings - Fork 11
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
home work #16
base: master
Are you sure you want to change the base?
home work #16
Conversation
@@ -0,0 +1,28 @@ | |||
file = open("C:/Users/tomer/PycharmProjects/HomeChallenge3/Readme.txt") | |||
words = open("C:/Users/tomer/PycharmProjects/HomeChallenge3/Readme.txt").read().split() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
there is no need to open file twice. "file" variable declared adlready
words = open("C:/Users/tomer/PycharmProjects/HomeChallenge3/Readme.txt").read().split() | ||
|
||
print(file.read()) | ||
print(words) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this output is not needed
print(words) | ||
|
||
|
||
def keywithmaxval(d): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
use '_' between word - should looks like: key_with_max_val
also, argument name should have some meaning, 'd' is not an acceptable argument name
|
||
|
||
def keywithmaxval(d): | ||
""" a) create a list of the dict's keys and values; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
docstring should contain:
- general description of the function
- arguments - brief description and their type
- returns - brief description and their type
|
||
print("max word is:", (word_count(words))) | ||
print(file.read()) | ||
file.close() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
using context manager( with...open...) is much better way to handle files operations. in case program will exit on error, file might remain opened
return keywithmaxval(counts), max(counts.values()) | ||
|
||
|
||
print("max word is:", (word_count(words))) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it is better using "main" function, that calling other functions
No description provided.