added the ability to pass book as a cli arg
This commit is contained in:
parent
6db3cdaa07
commit
df434df398
1 changed files with 4 additions and 3 deletions
7
main.py
7
main.py
|
|
@ -1,3 +1,4 @@
|
||||||
|
import sys
|
||||||
import string
|
import string
|
||||||
|
|
||||||
def open_book(book_path):
|
def open_book(book_path):
|
||||||
|
|
@ -28,7 +29,7 @@ def print_report(word_count,char_count):
|
||||||
for char in chars:
|
for char in chars:
|
||||||
print(f"The '{char}' character was found {char_count.get(char)} times")
|
print(f"The '{char}' character was found {char_count.get(char)} times")
|
||||||
print("--- End report ---")
|
print("--- End report ---")
|
||||||
|
book = sys.argv[1]
|
||||||
wc = count_words(open_book("books/frankenstein.txt"))
|
wc = count_words(open_book(book))
|
||||||
cc = count_char_instance(open_book("books/frankenstein.txt"))
|
cc = count_char_instance(open_book(book))
|
||||||
print_report(wc,cc)
|
print_report(wc,cc)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue