def bsearch(arr, x):
    min = 0
    max = len(arr) - 1
    
    while max >= min:
        mid = (min + max) // 2
        
        if x == arr[mid]:
            return mid 
            
        if x > arr[mid]:
            min = mid + 1 
        else:
            max = mid - 1 
            
    return None
    
arr = [1,2,3,4,5]
for i in range(7):
    print(bsearch(arr, i))

Embed on website

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