我是一个非常新的编码,似乎有我的工作,但我需要它拿起超过10的值作为一个错误。我不知道如何在不使用条件结构(if etc)
或重复(for, while)
的情况下实现它
while True:
try:
value = int(input("Enter an integer between 1 and 10: "))
reciprocal = 1 / value
print("The Reciprocal of your number is ", reciprocal, "\n")
except ValueError:
print("You did not enter an integer!!!\nPlease, try again.\n")
except ZeroDivisionError:
print("Oops, you entered zero.\nPlease, try again. \n")
目前没有回答
相关问题 更多 >
编程相关推荐