def bin_search(data,val):
high = len(data)-1
low = 0
while low <= high: # 考虑要查询的值在列表最两端 所以 low=high
mid = (low + high) // 2
if data[mid] == val:
return mid
elif data[mid] > val:
high = mid-1
else:
if data[mid] < val:
low = mid+1
return
a = [x for x in range(1,5)]
print(a)
b = bin_search(a,4)