From 34c08fc92c298b7d164d591e42b049c39312bc51 Mon Sep 17 00:00:00 2001 From: David Costell Date: Sat, 12 Mar 2022 16:34:20 +0800 Subject: [PATCH] Cat program revised (v2) (bugfix) Additional change: * Fixed improper behavior if no arguments were passed --- Cat/cat.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Cat/cat.py b/Cat/cat.py index df4df3bd75b..552ed6c1e7a 100644 --- a/Cat/cat.py +++ b/Cat/cat.py @@ -49,11 +49,11 @@ def no_files(): def main(): """Entry point of the cat program.""" - try: - # Read the arguments passed to the program - with_files(sys.argv[1:]) - except IndexError: + # Read the arguments passed to the program + if not sys.argv[1:]: no_files() + else: + with_files(sys.argv[1:]) if __name__ == "__main__": main()