python_day5--->递归函数,二分法查找
li = [1, 5, 6, 7, 12, 22, 33, 44, 55, 66, 77, 88, 99, 111, 222, 333]
def er(num,li):
if len(li) ==0:
print ('没有找到')
return num
WZ=len(li)//2
if num == li[WZ]:
print (num,'就是你要找的')
elif num > li[WZ]:
print ('小了')
li=li[WZ+1:]
return er(num,li)
elif num < li[WZ]:
print('大了')
li=li[:WZ]
return er(num, li)
er(23,li)