import random
import numpy as np
bot=int(input('数字区间最小值:n'))
top=int(input('数字区间最大值:n'))
rand=random.randint(bot,top)
print('随机数在['+str(bot)+','+str(top)+']之间生成!')
num=int((input('###猜测的数字:###n')))
cnt=1
a=str(bot)+','+str(top)+','+str(rand)+','+str(num)
b=a.split(",")#将str转换成list
b.sort(key=int)#将list按照升序排列
while (num!=rand):
position = b.index(str(rand))
print('随机数在['+b[position-1]+','+b[position+1]+']之间')
num = int((input('###猜测的数字:###n')))
c=str(num)
b.append(c)#将新输入的数字,追加至list中
b.sort(key=int)
cnt = cnt + 1
print('猜对答案花费次数:[%d]'%cnt)