diff --git a/ZeroDivisionErrorTreatment.py b/ZeroDivisionErrorTreatment.py new file mode 100644 index 00000000..4bd003c5 --- /dev/null +++ b/ZeroDivisionErrorTreatment.py @@ -0,0 +1,10 @@ +# Function below: +def division(x: int, y: int): + try: + return x / y + except ZeroDivisionError: + return None # Error Handled + +# tests +print(division(2, 3)) # 0.66666666... +print(division(6, 0)) # None \ No newline at end of file