Skip to content

Commit 33d638c

Browse files
committed
formatting the output
1 parent 541562d commit 33d638c

File tree

1 file changed

+12
-0
lines changed
  • implement-shell-tools/wc

1 file changed

+12
-0
lines changed

implement-shell-tools/wc/wc.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,18 @@
22
import sys
33
import os
44

5+
def format_output(lines, words, bytes_, label, options):
6+
output = ""
7+
if not (options.l or options.w or options.c):
8+
output += f"{lines:8}{words:8}{bytes_:8}"
9+
else:
10+
if options.l:
11+
output += f"{lines:8}"
12+
if options.w:
13+
output += f"{words:8}"
14+
if options.c:
15+
output += f"{bytes_:8}"
16+
return f"{output} {label}"
517

618
def main():
719
parser = argparse.ArgumentParser(description="Count lines, words, and bytes in files (like wc)")

0 commit comments

Comments
 (0)