Skip to content

Commit 914cfda

Browse files
committed
added counter function to count words, lines and characters from a path(s)
1 parent 4aad5ab commit 914cfda

1 file changed

Lines changed: 7 additions & 0 deletions

File tree

  • implement-shell-tools/wc

implement-shell-tools/wc/wc.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,8 +106,15 @@
106106
def counter(item):
107107
lines = len(item.trim().split("\n"))
108108
words = item.split()
109+
characters = len(item)
110+
return {lines, words, characters}
109111

110112

113+
total_lines = 0
114+
total_words = 0
115+
total_characters = 0
116+
file_count = 0
117+
111118

112119
for path in args.paths:
113120
with open(path, "r") as f:

0 commit comments

Comments
 (0)