Skip to content

Python-Home-Challenges-Maor Weiss #10

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

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
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
2 changes: 1 addition & 1 deletion Python-Home-Challenges/Challenge_01.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Create a python progarm that do the following:
Create a python progarm that do the following:
1. Reads a text file
2. Returns the most recurring word in that file.

Expand Down
3 changes: 3 additions & 0 deletions Python-Home-Challenges/Creating_file.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
cd /home/$USER/
echo "please do not do what ever you want to do" > file.txt

22 changes: 22 additions & 0 deletions Python-Home-Challenges/Python-home-challenge#01-MaorWeiss.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# HW03 - Open a text file and returns the most recurring word in that file.

with open(r'/home/$USER/', 'r') as fp:
f = fp.readline()
# Read file #
split_words_from_file = f.split()

# Creating variable for checking what is the recurring value #
biggest_counting = 0

for list_arg in split_words_from_file:
count = 0
for word in split_words_from_file:
if list_arg == word:
count += 1
if count > biggest_counting:
the_most_recurring_word = list_arg
biggest_counting = count


print(f"The most recurring word in the file is '{the_most_recurring_word}'")
print(f"which has appeared {biggest_counting} times.")
4 changes: 4 additions & 0 deletions Python-Home-Challenges/insructions_challenge#01.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
1. Open the "Creating_file.sh" file
2. execute the "Python-home-challenge#01-MaorWeiss.py" file

Have a nice day!