import random
while True:
print('*' * 30, '猜字游戏:猜一个1到100的整数', '*' * 30)
target = random.randint(1,100)
i = 1
while i <= 5:
guess = int(input("请输入你的猜测:"))
if guess == target:
print("猜对啦,正确数字是:%s"%guess)
else:
if guess > target:
print("猜大啦")
else:
print("猜小了")
change = 5 - i
print("再猜,还有%s次机会"%change)
i += 1
print("游戏结束,正确答案是:%s"%target)
python猜数字游戏
最新推荐文章于 2024-03-05 19:22:36 发布