count = 0 while count < 3: age = int(input(‘输入猜的年龄:‘))#输入的结构必须在循环体内,否则一直循环第一次输入的值 if age == 5: print(‘恭喜你,猜对了‘)#猜对了也可以继续玩下去 # b = input(‘是否要继续玩下去?,y/n:‘) # if b == ‘y‘: # count -= 3 # if b == ‘n‘: break elif age < 5: print(‘往大了猜‘) else: print(‘往小了猜‘) count += 1 if count == 3: b = input(‘是否要继续玩下去?,y/n:‘) if b == ‘y‘: count -= 3 if b == ‘n‘: break