# python 3.7 环境
while True:
n = int(input("请输入一个数来猜:\n"))
count = 1
print(('\n'*15))
g = int(input("请猜:\n"))
while g != n:
if g < n:
g = int(input("没猜对,{} 小了\n".format(g)))
else:
g = int(input("没猜对,{} 大了\n".format(g)))
count += 1
print("恭喜你猜对了, 答案是 %d,共猜了 %d 次" %(n, count))
扫码关注腾讯云开发者
领取腾讯云代金券
Copyright © 2013 - 2025 Tencent Cloud. All Rights Reserved. 腾讯云 版权所有
深圳市腾讯计算机系统有限公司 ICP备案/许可证号:粤B2-20090059 深公网安备号 44030502008569
腾讯云计算(北京)有限责任公司 京ICP证150476号 | 京ICP备11018762号 | 京公网安备号11010802020287
Copyright © 2013 - 2025 Tencent Cloud.
All Rights Reserved. 腾讯云 版权所有