Python hashing binary search : Write a binary_search function which at each step prints the list being searched as in the following output. It shows both the sublist currently being searched and then how that gets split into two parts around the midpoint.

This is what I have tried, but still struggle to find the solution:

    def binary_search(a_list, item):
    print(a_list) # just to show the search area
    if a_list == []:
        return False
    midpoint = len(a_list) // 2
    element = a_list[midpoint]
    if item == element:
        return True
    elif item < element: # first half
        return binary_search(a_list[:midpoint], item)
    else:
        return binary_search(a_list[midpoint+1:], item)

Could someone please help me? Here is the sample answer: [sample][1]


  [1]: https://i.stack.imgur.com/7Bfm1.png