Python icon indicating copy to clipboard operation
Python copied to clipboard

Add input validation for division by zero in divide_numbers()

Open Vedavyasa21 opened this issue 2 months ago • 8 comments

Feature description

Currently, the divide_numbers(a, b) function in maths/division.py performs basic division but lacks input validation for zero denominators. While Python’s built-in behavior raises a ZeroDivisionError, adding explicit validation would make the function more robust and user-friendly — especially for beginners using this repository to learn algorithms.

This feature would ensure that the function provides clearer feedback and better error handling, aligning with educational best practices

def divide_numbers(a, b):
    if b == 0:
        raise ValueError("Cannot divide by zero. Please provide a non-zero denominator.")
    return a / b

Vedavyasa21 avatar Nov 03 '25 02:11 Vedavyasa21

@Vedavyasa21 are you working on this, or can I take?

ADITI-MISHRA310 avatar Nov 03 '25 13:11 ADITI-MISHRA310

You can try.

Vedavyasa21 avatar Nov 03 '25 13:11 Vedavyasa21

Thanks @Vedavyasa21, going to work on this and will soon update here only.

ADITI-MISHRA310 avatar Nov 03 '25 13:11 ADITI-MISHRA310

@Vedavyasa21 there is no division.py file in maths/, can you confirm

ADITI-MISHRA310 avatar Nov 03 '25 13:11 ADITI-MISHRA310

If the file maths/division.py does not exist, please confirm the correct path for the function or module where division logic resides (e.g., maths/basic_operations.py or maths/arithmetic.py).

Vedavyasa21 avatar Nov 03 '25 15:11 Vedavyasa21

The issue and comments by @Vedavyasa21 appear to be AI slop. @Vedavyasa21I see you're trying to get onboard with open source development, but this is spam. Make sure your AI does not hallucinate.

@cclauss please moderate this

dargmuesli avatar Nov 07 '25 18:11 dargmuesli

Hey @dargmuesli I used AI for description but idea itself was mine. I’m still learning how to contribute properly and did not want to create spam or confusion.

Vedavyasa21 avatar Nov 08 '25 03:11 Vedavyasa21

Please indicate the source of the divide_numbers function then.

dargmuesli avatar Nov 08 '25 21:11 dargmuesli