Skip to content

Commit 6e504ed

Browse files
committed
Final version of pywc
1 parent 1b2fda2 commit 6e504ed

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

pywc/wc.py

+6-6
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,12 @@
66
"""
77

88
import argparse
9-
import sys
109

1110

1211
def parse_args() -> tuple[list[str], str]:
13-
parser = argparse.ArgumentParser(description="Python implementation of the core-utils wc")
12+
parser = argparse.ArgumentParser(
13+
description="Python implementation of the core-utils wc"
14+
)
1415
parser.add_argument("-l", "--lines", action="store_true")
1516
parser.add_argument("-w", "--words", action="store_true")
1617
parser.add_argument("-c", "--characters", action="store_true")
@@ -37,7 +38,7 @@ def get_words(content):
3738

3839

3940
def count_characters(content: list[str]):
40-
words = get_words()
41+
words = get_words(content)
4142
characters = [len(word) for word in words]
4243
return sum(characters)
4344

@@ -50,14 +51,13 @@ def count_characters(content: list[str]):
5051

5152
lines_count = count_lines(lines)
5253
words_count = count_words(lines)
53-
54-
characters_count = count_characters()
54+
characters_count = count_characters(lines)
5555

5656
if args.lines:
5757
print(lines_count, end=" ")
5858
if args.words == "-w":
5959
print(words_count, end=" ")
6060
if args.characters == "-c":
6161
print(characters_count, end=" ")
62-
if not any(args.lines, args.words, args.characters):
62+
if not any((args.lines, args.words, args.characters)):
6363
print(lines_count, words_count, characters_count)

0 commit comments

Comments
 (0)