Skip to content

Commit 14fca64

Browse files
committed
moving code inside helper function process_file
1 parent 9f5649f commit 14fca64

1 file changed

Lines changed: 7 additions & 6 deletions

File tree

  • implement-shell-tools/wc

implement-shell-tools/wc/wc.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,13 @@ def process_file(file_path):
3636
elif args.char:
3737
print(f"{stats['characters']} {file_path}}")
3838
else:
39-
print(f"{stats['lines']} {stats['words']} {stats['characters']} {file_path}}")
39+
print(f"{stats['lines']} {stats['words']} {stats['characters']} {file_path}")
40+
41+
42+
total_lines += stats['lines']
43+
total_words += stats['words']
44+
total_characters += stats['characters']
45+
file_count += 1
4046

4147

4248
total_lines = 0
@@ -51,11 +57,6 @@ def process_file(file_path):
5157

5258

5359

54-
total_lines += stats['lines']
55-
total_words += stats['words']
56-
total_characters += stats['characters']
57-
file_count += 1
58-
5960
elif os.path.isdir(path):
6061
for file in os.listdir(path):
6162
file_path = os.path.join(path, file)

0 commit comments

Comments
 (0)