-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
40 lines (30 loc) · 988 Bytes
/
main.py
File metadata and controls
40 lines (30 loc) · 988 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
import sys
def get_book_text(path_to_file):
with open(path_to_file) as f:
file_contents = f.read()
return file_contents
def main():
if len(sys.argv) != 2:
print("Usage: python3 main.py <path_to_book>")
sys.exit(1)
else:
path_to_file = sys.argv[1]
print("============ BOOKBOT ============")
print(f"Analyzing book found at {path_to_file}...")
print("----------- Word Count ----------")
print(f"Found {number_of_words(get_book_text(path_to_file))} total words")
print("--------- Character Count -------")
for item in sorted(get_book_text(path_to_file)):
print(f"{item['letter']}: {item['num']}")
print("============= END ===============")
from stats import (
number_of_words,
num_of_characters,
sort_on,
sorted
)
# from stats import num_of_characters
# from stats import sort_on
# from stats import sorted
# from stats import report
main()