Binary search
Write binary_search(sorted_list, target) that returns the index of target, or -1 if absent. Halve the search range each step; do not scan linearly.
Examples
binary_search([1, 3, 5, 7, 9], 7) → 3
Exercise
5 checksBinary search
def binary_search(sorted_list, target):
lo, hi = 0, len(sorted_list) - 1
...
print(binary_search([1, 3, 5, 7, 9], 7))
Press Run to try your code, then Check answer to grade it.