Skip to content

Commit 3daf387

Browse files
Add files via upload
1 parent 94d21cc commit 3daf387

File tree

1 file changed

+60
-13
lines changed

1 file changed

+60
-13
lines changed

Section_06/assignment_01.py

+60-13
Original file line numberDiff line numberDiff line change
@@ -12,21 +12,68 @@
1212
# Expected Output:
1313
# {"there": n, "Michael": n, "running": n}
1414

15-
words_and_counts = {}
15+
# Your Code Below:
1616

17-
for word in words_to_aggregate:
18-
count = 0
19-
for path, folder_names, file_names in os.walk(directory_containing_files):
20-
for file_name in file_names:
21-
file = os.path.join(path, file_name)
22-
with open(file, "r") as a_file:
23-
for line in a_file:
24-
if re.search(word, line):
25-
word_list = re.findall(word, line)
26-
count += len(word_list)
2717

28-
words_and_counts[word] = count
2918

3019

3120

32-
print(words_and_counts)
21+
22+
23+
24+
25+
26+
27+
28+
29+
30+
31+
32+
33+
34+
35+
36+
37+
38+
39+
40+
41+
42+
43+
44+
45+
46+
47+
48+
49+
50+
51+
52+
53+
54+
55+
56+
57+
58+
59+
60+
61+
#Solution:
62+
# words_and_counts = {}
63+
#
64+
# for word in words_to_aggregate:
65+
# count = 0
66+
# for path, folder_names, file_names in os.walk(directory_containing_files):
67+
# for file_name in file_names:
68+
# file = os.path.join(path, file_name)
69+
# with open(file, "r") as a_file:
70+
# for line in a_file:
71+
# if re.search(word, line):
72+
# word_list = re.findall(word, line)
73+
# count += len(word_list)
74+
#
75+
# words_and_counts[word] = count
76+
#
77+
#
78+
#
79+
# print(words_and_counts)

0 commit comments

Comments
 (0)