当tryAgain在没有输入任何内容的情况下执行然后按回车键或输入随机单词和数字时,数字函数被绕过if语句调用。那是为什么?
def number():
try:
num = input("Enter a number! ")
x = int(num)
print("You input {} which is a number".format(num))
except ValueError:
print("{} is not a number!".format(num))
tryAgain = input("Want to try again?[Y/N] ") #this one right here
if tryAgain.lower() != 'n':
number()
number()