我正在尝试让用户输入一个介于1和4之间的数字。我已经编写了代码来检查数字是否正确,但我希望代码能循环多次,直到数字正确为止。有人知道如何做到这一点吗?以下是代码:
我也遇到了一个关于我输入的异常的错误。
感谢任何帮助。
def Release():
try:
print 'Please select one of the following?\nCompletion = 0\nRelease ID = 1\nVersion ID = 2\nBuild ID = 3\n'
a = int(input("Please select the type of release required: "))
if a == 0:
files(a)
elif a == 1:
files(a)
elif a == 2:
files(a)
elif a == 3:
files(a)
else:
raise 'incorrect'
except 'incorrect':
print 'Try Again'
except:
print 'Error'
Release()
我也遇到了一个关于我输入的异常的错误。
kill.py:20: DeprecationWarning: catching of string exceptions is deprecated
except 'incorrect':
Error
感谢任何帮助。