We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 02de813 commit 466c007Copy full SHA for 466c007
1 file changed
implement-shell-tools/wc/wc.py
@@ -8,15 +8,25 @@
8
9
args = parser.parse_args()
10
11
+lines = 0
12
+words = 0
13
+bytes = 0
14
+
15
dict = {}
16
17
for file in args.path:
18
f = open(file)
- text = []
- text.append(f.read())
- dict[file] = text
-
19
+ # text = []
20
+ # text.append(f.read().split("\n"))
21
+ # print(f.read().split("\n"))
22
+ dict[file] = f.read().split("\n")
23
+# print(dict)
24
for f in dict:
- print(dict[f])
25
+ word_per_line = 0
26
+ byte_per_line = 0
27
+ for l in dict[f]:
28
+ word_per_line += len(l.split())
29
+ byte_per_line += len(l.encode("utf-8"))
30
+ # print(byte_per_line)
31
+ print(str(len(dict[f]) - 1) + " " + str(word_per_line) + " " + f)
32
-# print(dict)
0 commit comments