请问判断语句后的输入,为什么还可以重新进入到判断语句中重新判断
born_year = int(input("Enter the year you born:"))
this_year = int(input("Enter this year:"))
while this_year < born_year:
print("your age can't be negative,please enter agagin.")
born_year = int(input("Enter the year you born:"))
this_year = int(input("Enter this year:"))
else:
print("Input successed")
print("your age is",this_year - born_year)
为什么重新输入born_year和this_year时候,就会重新判断?
因为输入以后,会返回while循环比较这两个值,从而决定是继续循环,还是执行后面的else。
while this_year < born_year