Skip to content

Commit a477e1b

Browse files
author
github-pi-bot
committed
Fix issue #2: Add zero division guard to divide() function
- Added guard to check if divisor (b) is zero - Raises ValueError with descriptive message instead of ZeroDivisionError - Prevents crashes when calling divide() with zero divisor
1 parent 434ed79 commit a477e1b

1 file changed

Lines changed: 2 additions & 1 deletion

File tree

src/calculator.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,5 +14,6 @@ def multiply(a: int, b: int) -> int:
1414

1515

1616
def divide(a: int, b: int) -> float:
17-
# Intentional bug: no zero-division guard. Reported via issue → gp:auto-fix.
17+
if b == 0:
18+
raise ValueError("Cannot divide by zero")
1819
return a / b

0 commit comments

Comments
 (0)