Skip to content

Commit

Permalink
Adds default when no args passed
Browse files Browse the repository at this point in the history
  • Loading branch information
ASproson committed May 6, 2024
1 parent 17d812f commit 9ca14df
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion ccwc.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,15 @@ def main():
parser.add_argument("-w", "--words", action='store_true', help="Count the number of words in the specified file")
parser.add_argument("-m", "--characters", action='store_true', help="Count the number of characters in the specified file")


args = parser.parse_args()
file = args.filename

if not(args.lines or args.words or args.characters):
line_count = count_lines(file)
word_count = count_words(file)
char_count = count_chars(file)
print(f"{line_count} {word_count} {char_count} {file}")

if args.lines:
line_count = count_lines(file)
print(f"Number of lines in {file}: {line_count}")
Expand All @@ -46,5 +51,7 @@ def main():
char_count = count_chars(file)
print(f"Number of characters in {file}: {char_count}")



if __name__ == "__main__":
main()

0 comments on commit 9ca14df

Please sign in to comment.