Skip to content

Commit 4a8a83e

Browse files
committed
Proper variable names for dicts
1 parent f89d3d8 commit 4a8a83e

1 file changed

Lines changed: 9 additions & 10 deletions

File tree

  • implement-shell-tools/wc

implement-shell-tools/wc/wc.py

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -21,17 +21,16 @@
2121
w = args.words
2222
c = args.bytes
2323

24-
dict = {}
25-
adict = {}
24+
file_data = {}
25+
file_data_with_newline = {}
2626

2727
for file in args.path:
2828
f = open(file)
29-
dict[file] = f.read().split("\n")
30-
adict[file] = f.read()
29+
file_data[file] = f.read().split("\n")
3130

3231
for file in args.path:
3332
f = open(file)
34-
adict[file] = f.read()
33+
file_data_with_newline[file] = f.read()
3534

3635
def print_helper(line, word, byte, file_name):
3736
text = [" "]
@@ -47,17 +46,17 @@ def print_helper(line, word, byte, file_name):
4746
text.append(file_name)
4847
print("".join(text))
4948

50-
for f in dict:
49+
for f in file_data:
5150
word_per_line = 0
5251
byte_per_line = 0
53-
for line in dict[f]:
52+
for line in file_data[f]:
5453
word_per_line += len(line.split())
55-
for line in adict[f]:
54+
for line in file_data_with_newline[f]:
5655
byte_per_line += len(line.encode("utf-8"))
57-
lines += len(dict[f]) - 1
56+
lines += len(file_data[f]) - 1
5857
words += word_per_line
5958
bytes += byte_per_line
60-
print_helper(len(dict[f]) - 1, word_per_line, byte_per_line, f)
59+
print_helper(len(file_data[f]) - 1, word_per_line, byte_per_line, f)
6160

6261
if len(args.path) > 1:
6362
print_helper(lines, words, bytes, "total")

0 commit comments

Comments
 (0)