book_ids = [105, 210, 305, 412, 550, 720]
find = 412

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

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

    if book_ids[mid] == find:
        answer = mid
        break
    elif book_ids[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: