-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
22 lines (18 loc) · 669 Bytes
/
main.py
File metadata and controls
22 lines (18 loc) · 669 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
from stats import get_num_words, get_char_count, sort_chars
import sys
def main():
if len(sys.argv) < 2:
print("Usage: python3 main.py <path_to_book>")
sys.exit(1)
path = sys.argv[1]
num_words = get_num_words(path)
sorted_chars = sort_chars(get_char_count(path))
print("============ BOOKBOT ============")
print(f"Analyzing book found at {path}...")
print("----------- Word Count ----------")
print(f"Found {num_words} total words")
print("--------- Character Count -------")
for tuple in sorted_chars:
print(f"{tuple["char"]}: {tuple["count"]}")
print("============= END ===============")
main()