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