File tree Expand file tree Collapse file tree 1 file changed +12
-3
lines changed
Expand file tree Collapse file tree 1 file changed +12
-3
lines changed Original file line number Diff line number Diff line change 33
44parser = argparse .ArgumentParser (description = "Python implementation of wc command" )
55
6+ parser .add_argument ("-l" , action = "store_true" , help = "Print line count" )
7+
68parser .add_argument ("files" , nargs = "+" , help = "Files to process" )
79
810args = parser .parse_args ()
2830 total_lines += lines
2931 total_words += words
3032 total_bytes += tbytes
31-
32- print (f"{ lines :>7} { words :>7} { tbytes :>7} { file } " ) # to print data from per life
33+
34+ if args .l :
35+ print (f"{ lines :} { file } " )
36+
37+ else :
38+ print (f"{ lines :>3} { words :>3} { tbytes :>3} { file } " ) # to print data from per life
3339
3440#to print total output
3541if multiple_files :
36- print (f"{ total_lines :>7} { total_words :>7} { total_bytes :>7} total" )
42+ if args .l :
43+ print (f"{ total_lines :} total" )
44+ else :
45+ print (f"{ total_lines :>3} { total_words :>3} { total_bytes :>3} total" )
3746
3847
3948
You can’t perform that action at this time.
0 commit comments