Skip to content

Commit 350c3f2

Browse files
committed
done changes according to review
1 parent 5ddd011 commit 350c3f2

File tree

1 file changed

+7
-15
lines changed
  • implement-shell-tools/wc

1 file changed

+7
-15
lines changed

implement-shell-tools/wc/wc.py

Lines changed: 7 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
args.w = args.c = args.l = True
3030
numbers = []
3131
output = []
32-
32+
column_widths = []
3333
for path in args.path:
3434
output_for_one_file = []
3535
if args.l or args.w:
@@ -64,20 +64,12 @@
6464

6565
num_cols = len(total_results) - 1
6666
column_widths = [len(str(total_results[i])) for i in range(num_cols)]
67-
68-
for row in output:
69-
line_parts = []
70-
for i in range(num_cols):
71-
# Right-align with 1 space padding (like wc)
72-
line_parts.append(str(row[i]).rjust(column_widths[i] + 7))
73-
print("".join(line_parts), row[-1])
7467
elif len(args.path) == 1:
7568
num_cols = len(output[0]) - 1
76-
print(num_cols)
7769
column_widths = [len(str([output[0][i]])) for i in range(num_cols)]
78-
for row in output:
79-
line_parts = []
80-
for i in range(num_cols):
81-
# Right-align with 1 space padding (like wc)
82-
line_parts.append(str(row[i]).rjust(column_widths[i] + 6))
83-
print("".join(line_parts), row[-1])
70+
for row in output:
71+
line_parts = []
72+
for i in range(num_cols):
73+
# Right-align with 1 space padding (like wc)
74+
line_parts.append(str(row[i]).rjust(column_widths[i] + 6))
75+
print("".join(line_parts), row[-1])

0 commit comments

Comments
 (0)