需求:输入年龄,有三次机会。如果超三次,提示“输入次数超3次,退出”
代码:
age_oldBoy = 56count=0while count<3: age=int(input("input age:")) if age_oldBoy==age: print("输入正确") break elif age>age_oldBoy: print("输入大了") else: print("输入小了") count+=1else: print("输入次数超3次,退出")