File tree 1 file changed +60
-13
lines changed
1 file changed +60
-13
lines changed Original file line number Diff line number Diff line change 12
12
# Expected Output:
13
13
# {"there": n, "Michael": n, "running": n}
14
14
15
- words_and_counts = {}
15
+ # Your Code Below:
16
16
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 )
27
17
28
- words_and_counts [word ] = count
29
18
30
19
31
20
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)
You can’t perform that action at this time.
0 commit comments