# 需求:根据用户输入的数字进行猜数字游戏,标签:数字,python,else,print,小游戏,answer From: https://www.cnblogs.com/chen1024a/p/17808668.html
要求:数字的范围(1,100),且最多有7次机会
from random import randint
answer = randint(0, 100)
for i in range(7):
you_answer = input("请输入一个整数:")
if you_answer.isdigit():
you_answer = int(you_answer)
if you_answer > answer:
print("大了")
elif you_answer < answer:
print("小了")
else:
print("您猜对了!!!")
break
else:
print("请输入一个整数呗!!")
else:
print("次数用完!!!")