From 5bd2b221984f34d767f22c7a51a9237a77bc4c9d Mon Sep 17 00:00:00 2001 From: Achintya singh Date: Sat, 6 Jun 2026 20:51:16 +0530 Subject: [PATCH 1/4] Fix syntax error in exception handling for greatest_common_divisor --- maths/greatest_common_divisor.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/maths/greatest_common_divisor.py b/maths/greatest_common_divisor.py index ce0abc664cf9..540a60f55862 100644 --- a/maths/greatest_common_divisor.py +++ b/maths/greatest_common_divisor.py @@ -73,7 +73,7 @@ def main(): f"{greatest_common_divisor(num_1, num_2)}" ) print(f"By iterative gcd({num_1}, {num_2}) = {gcd_by_iterative(num_1, num_2)}") - except IndexError, UnboundLocalError, ValueError: + except (IndexError, ValueError): print("Wrong input") From 0b936d78c5d5d94e125aedcc4d6a73b6ed939090 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Sat, 6 Jun 2026 15:09:19 +0000 Subject: [PATCH 2/4] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- maths/greatest_common_divisor.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/maths/greatest_common_divisor.py b/maths/greatest_common_divisor.py index 540a60f55862..7525d75e6d91 100644 --- a/maths/greatest_common_divisor.py +++ b/maths/greatest_common_divisor.py @@ -73,7 +73,7 @@ def main(): f"{greatest_common_divisor(num_1, num_2)}" ) print(f"By iterative gcd({num_1}, {num_2}) = {gcd_by_iterative(num_1, num_2)}") - except (IndexError, ValueError): + except IndexError, ValueError: print("Wrong input") From f382f6a2c19a2215a98347a48a01118240bd36c2 Mon Sep 17 00:00:00 2001 From: Achintya singh Date: Sat, 6 Jun 2026 22:08:10 +0530 Subject: [PATCH 3/4] Refine logic paths in greatest common divisor --- maths/greatest_common_divisor.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/maths/greatest_common_divisor.py b/maths/greatest_common_divisor.py index 7525d75e6d91..a013951d9fe2 100644 --- a/maths/greatest_common_divisor.py +++ b/maths/greatest_common_divisor.py @@ -77,5 +77,3 @@ def main(): print("Wrong input") -if __name__ == "__main__": - main() From d139a2c322eb00ab37f3e8f6509d655eeb948fd4 Mon Sep 17 00:00:00 2001 From: Achintya singh Date: Sat, 6 Jun 2026 22:24:10 +0530 Subject: [PATCH 4/4] Fix syntax error by wrapping multiple exceptions in a tuple --- maths/greatest_common_divisor.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/maths/greatest_common_divisor.py b/maths/greatest_common_divisor.py index a013951d9fe2..f2f5510f9bd8 100644 --- a/maths/greatest_common_divisor.py +++ b/maths/greatest_common_divisor.py @@ -73,7 +73,7 @@ def main(): f"{greatest_common_divisor(num_1, num_2)}" ) print(f"By iterative gcd({num_1}, {num_2}) = {gcd_by_iterative(num_1, num_2)}") - except IndexError, ValueError: + except (IndexError, ValueError): print("Wrong input")