def recursive_binary_search(list, target):
    if(len(list) == 0):
        return False
    else:
        midpoint = len(list) // 2
        if(list[midpoint] == target):
            return midpoint
        else:
            if(list[midpoint] < target):
                return recursive_binary_search(list[midpoint + 1:], target)
            else:
                return recursive_binary_search(list[:midpoint], target)


def verify(index):
    if(index != None):
        print("Target found at index: ", index)
    else:
        print("Target not found in list")


numbers = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]

result = recursive_binary_search(numbers, 12)
verify(result)

result = recursive_binary_search(numbers, 6)
verify(result)

Embed on website

To embed this project on your website, copy the following code and paste it into your website's HTML: