Python全栈之路_day1

1.在限制猜年龄次数的情况下,如果次数不够了,询问是否增加猜测次数。

age = 60
i = 1
while i <=3:
temp = int(input("请输入年龄:"))
if temp < age:
print("小了")
elif temp > age:
print("大了")
else:
print("恭喜猜对了")
break
i = i + 1
if i == 4:
jx = input("是否要继续猜年龄(y or n):")
if jx != 'n':
i = 1

猜你喜欢

转载自www.cnblogs.com/dear-meng/p/9783305.html