added the ability to pass book as a cli arg

This commit is contained in:
specCon18 2025-01-09 21:55:14 -05:00
parent 6db3cdaa07
commit df434df398

View file

@ -1,3 +1,4 @@
import sys
import string
def open_book(book_path):
@ -28,7 +29,7 @@ def print_report(word_count,char_count):
for char in chars:
print(f"The '{char}' character was found {char_count.get(char)} times")
print("--- End report ---")
wc = count_words(open_book("books/frankenstein.txt"))
cc = count_char_instance(open_book("books/frankenstein.txt"))
book = sys.argv[1]
wc = count_words(open_book(book))
cc = count_char_instance(open_book(book))
print_report(wc,cc)