12 lines
326 B
Python
12 lines
326 B
Python
# Write a Python program to handle a ZeroDivisionError exception when dividing a number by zero
|
|
|
|
|
|
def divide(x, y)
|
|
try:
|
|
# try to divide the provided values and store in variable: answer
|
|
answer = x / y
|
|
print(answer)
|
|
except ZeroDivisionError:
|
|
print("Enter a non-zero value")
|
|
|
|
divide(6, 2) |