Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Noam ossia's challenge HW #12

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
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
19 changes: 19 additions & 0 deletions Python-Home-Challenges/NoamChallenge.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@

with open('sample.txt', 'r') as file:
data = file.read().replace('\n', '')
print("The content of the file is:\n\n" + data)
Copy link
Contributor

Choose a reason for hiding this comment

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

plz use f' string instead,
also, this output is not needed



import re
Copy link
Contributor

Choose a reason for hiding this comment

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

all imports should be at the head of the file

words = re.sub("[^\w]", " ", data).split()

for word in words:
from collections import Counter
Copy link
Contributor

Choose a reason for hiding this comment

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

Never use import within a loop

word_counts = Counter(words)

MOword = word_counts.most_common(1)[0][0]
Copy link
Contributor

Choose a reason for hiding this comment

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

you should not use this module to solve the challenge. your should write your own algorithm

MOtimes = word_counts.most_common(1)[0][1]

print("\nThe most occuring word is {} and it occurs {} times".format(MOword,MOtimes))
Copy link
Contributor

Choose a reason for hiding this comment

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

using f' string is best practice for python3, plz use this method



1 change: 1 addition & 0 deletions Python-Home-Challenges/sample.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
I would love to try or hear the sample audio your app can produce. I do not want to purchase, because I've purchased so many apps that say they do something and do not deliver. Can you please add audio samples with text you've converted? I'd love to see the end results.Thanks!sfsdfasf