-
Notifications
You must be signed in to change notification settings - Fork 11
Coding challenge 0.1 #8
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
base: master
Are you sure you want to change the base?
Changes from 3 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,21 @@ | ||
|
|
||
| def most_common_word(file_name): | ||
| words_dict={} | ||
| with open(file_name) as file: | ||
| data_set=file.read() | ||
| split_it= data_set.split() | ||
| for word in split_it: | ||
| if word in words_dict.keys(): | ||
| words_dict[word]+=1 | ||
| else: | ||
| words_dict.update({word:1}) | ||
| maximum = max(words_dict, key=words_dict.get) | ||
| print(maximum, words_dict[maximum]) | ||
|
|
||
|
|
||
|
|
||
| if __name__== "__main__": | ||
| file_name = input("insert file path: ") | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. it is a bit risky to ask user to enter file name, if your decision is to do so, you man want to use some validation for his input |
||
| most_common_word(file_name) | ||
|
|
||
|
|
||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. please make sure you code pass Flask8 lint validation |
||
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.
+1 for using functions
but, best practice, is to create few functions, with each one of them doing 1 thing only