import random answer = random.randrange(1, 101) counter = 0 number = 0 while True: counter += 1 number += 1 user_answer = int(input('请输入你猜的数字: ')) if user_answer < answer: print('再大一点') print(f'猜测次数是:{number}') elif user_answer > answer: print('再小一点') print(f'猜测次数是:{number}') else: print('恭喜你猜对了') print(f'猜测次数是:{number}') break if counter > 7: print('温馨提示,你的智商余额不足')
python猜数字小游戏
最新推荐文章于 2024-11-09 21:51:27 发布