Skip to content

Commit d996f5b

Browse files
committed
corrected bugs in counter function
1 parent c70d7d9 commit d996f5b

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
@@ -104,10 +104,10 @@
104104
args = parser.parse_args()
105105

106106
def counter(item):
107-
lines = len(item.trim().split("\n"))
108-
words = item.split()
107+
lines = len(item.strip().split("\n"))
108+
words = len(item.split())
109109
characters = len(item)
110-
return {lines, words, characters}
110+
return {"lines": lines, "words": words, "characters": characters}
111111

112112

113113
total_lines = 0
@@ -121,7 +121,7 @@ def counter(item):
121121
content = f.read()
122122
stats = counter(content)
123123
if args.line:
124-
print(f"{lines} {path}")
124+
print(f"{stats[lines]} {path}")
125125
elif args.word:
126126
print()
127127
elif args.char:

0 commit comments

Comments
 (0)