def search2(a,m):
low = 0
high = len(a) - 1
while low<=high:
mid = (low + high)/2
midval = a[mid]
if midval<m:
low = mid + 1
elif midval>m:
high = mid-1
else:
print mid
return mid
print -1
return -1
这是我在网上粘的别人写的,我不懂为什么最后两行会print和return的是-1???不管if,elif,else,讨论完了都该返回查找结果啊,就是这个数在哪不是吗