# program to print the reciprocal of even numbers
num = int(input("Enter a number: "))
try:
assert num % 2 == 0
except ZeroDivisionError:
print(err)
except:
print("Not an even number!")
else:
reciprocal = 1/num
print(reciprocal)
该代码无法正常工作并给出以下错误:
---------------------------------------------------------------------------
ZeroDivisionError Traceback (most recent call last)
<ipython-input-41-ce890375558f> in <module>
8 print("Not an even number!")
9 else:
---> 10 reciprocal = 1/num
11 print(reciprocal)
ZeroDivisionError: division by zero
BIG阳
ibeautiful
暮色呼如
相关分类