Skip to content

Commit d5a3942

Browse files
committed
wc formatting matches real formatting exactly.
1 parent 575f0bf commit d5a3942

1 file changed

Lines changed: 4 additions & 4 deletions

File tree

  • implement-shell-tools/wc

implement-shell-tools/wc/wc.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,20 +40,20 @@
4040

4141
line_count = len(lines)
4242
totals["l"] += line_count
43-
output_str += f"\t{line_count}"
43+
output_str += f"{line_count:8}"
4444

4545
if (args.w):
4646
word_count = 0
4747
for line in lines:
4848
# python string.split splits on any white space
4949
word_count += len(line.split())
5050
totals["w"] += word_count
51-
output_str += f"\t{word_count}"
51+
output_str += f"{word_count:8}"
5252

5353
if (args.c):
5454
bytes = os.path.getsize(path)
5555
totals["c"] += bytes
56-
output_str += f"\t{bytes}"
56+
output_str += f"{bytes:8}"
5757

5858
output_str += f" {path}"
5959
print(output_str)
@@ -63,7 +63,7 @@
6363
if val != 0}
6464
total_str = ""
6565
for v in res.values():
66-
total_str += f"\t{v}"
66+
total_str += f"{v:8}"
6767

6868
total_str += " total"
6969
print(total_str)

0 commit comments

Comments
 (0)