甚至问这个我都觉得很尴尬,但是python出于某种原因一直给我一个错误的“l”
def binary_search(l, targetValue):
low = 0, high = len(array)
while low <= high:
mid = (high - low)/2
if l[mid] == targetValue:
return "we found it!"
elif l[mid] > targetValue:
low = mid - 1;
else l[mid] < targetValue: #this line seems to be the problem
high = mid + 1;
print "search failure :( "