#猜随机数1-10之间的随机数,共有五次机会,猜小了提示猜小了,猜大了提示猜大了,猜正确了提示“你好棒”并退出,五次还没有猜中提示“你好笨”!
import random
random_num = random.randint(0,10)
print(random_num)
count = 1#计数器
while count<6:
num = int(input('请输入你猜测的数字:'))
if num < random_num:
print('你猜的小了,往大了猜试试')
elif num > random_num:
print('你猜的大了,往小了猜试试')
else:
print('恭喜你五次之内猜对了')
break
count +=1
if count == 6:
print('哎,五次之内都没猜对')