File size: 426 Bytes
a1a7070 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 | ### Instruction:
Give me a working Python function for binary_search.
### Answer:
```python
def binary_search(items, target):
low = 0
high = len(items) - 1
while low <= high:
mid = (low + high) // 2
value = items[mid]
if value == target:
return mid
if value < target:
low = mid + 1
else:
high = mid - 1
return -1
```
### Instruction: |