Answers for "python catching division by zero"

1

python division by zero

def division(n, d):
    return n / d if d else 0
Posted by: Guest on June-15-2021
0

handling zero division error in python

x = 0
try:
  answer = 1/x
except ZeroDivisionError:
  answer = 'undefined'
print('The answer is {result}'.format(result=answer)
Posted by: Guest on May-25-2021

Code answers related to "python catching division by zero"

Python Answers by Framework

Browse Popular Code Answers by Language