Add input validation for division by zero in divide_numbers()
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 are you working on this, or can I take?
You can try.
Thanks @Vedavyasa21, going to work on this and will soon update here only.
@Vedavyasa21 there is no division.py file in maths/, can you confirm
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).
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
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.
Please indicate the source of the divide_numbers function then.