From df434df39854b1d77e9ab1ad7ddf3af955dbb586 Mon Sep 17 00:00:00 2001 From: specCon18 Date: Thu, 9 Jan 2025 21:55:14 -0500 Subject: [PATCH] added the ability to pass book as a cli arg --- main.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/main.py b/main.py index ff246c4..f182353 100644 --- a/main.py +++ b/main.py @@ -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)