Python全栈课程-第一章练习题-猜年龄游戏

real_age = 38
count = 0

while count < 3:
age = int(input('请输入年龄:'))
if age > real_age:
print('猜的大了,往小试试...')
elif age < real_age:
print('猜的小了,往大试试...')
else:
print('恭喜!你猜对了!')
break

count += 1

if count == 3:
confirm = input('笨蛋,猜错了3次,还想继续吗?输入y or Y:')
if confirm == 'y' or confirm == 'Y':
count = 0

猜你喜欢

转载自www.cnblogs.com/eric99/p/9970958.html