-
Notifications
You must be signed in to change notification settings - Fork 11
HW Python - Saar Cohen #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
base: master
Are you sure you want to change the base?
Changes from 1 commit
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,22 @@ | ||
|
|
||
| where_file = input('Enter the file route: ') | ||
| my_file = open(where_file,"r") | ||
| print("Your file text is:") | ||
| for x in my_file: | ||
| print(x) | ||
| print("---------------") | ||
| words_in_text = dict() | ||
| my_file = open(where_file,"r") | ||
|
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. you dont need to open file again, also, file must be closed after ward. best practice is to use "open...with" when working with files.
Author
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. roger that!
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. you dont need to open file again
Author
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. fix. |
||
| for line in my_file: | ||
| line = line.strip() | ||
| words = line.split(" ") | ||
| for word in words: | ||
| if word in words_in_text: | ||
| words_in_text[word] = words_in_text[word] + 1 | ||
| else: | ||
| words_in_text[word] = 1 | ||
| for key in list(words_in_text.keys()): | ||
| print(key, ":", words_in_text[key]) | ||
| print("---------------") | ||
| print (max(words_in_text.values())) | ||
|
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. check you code again, output is wrong
Author
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. now its working with nice output |
||
|
|
||
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 required
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.
that was just for my debugging, will be deleted.