arr = [3,6,12,7,1,11,9]
find = 11

left = 0
right = len(arr) - 1
answer = 0

while left <= right:
    mid = (left+right) // 2

    if arr[mid] == find:
        answer = mid
        break
    elif arr[mid] < find:
        left = mid + 1
    else:
        right = mid -1

print(answer)

Embed on website

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