Binary search implementation Is there a better way to implement a binary search than I am in my code? My function is taking two two lists - first_booth_voters and second_booth_voters with second_booth_voters being sorted and first_booth_voters not sorted. I feel like I am making an unnecessary amount of comparisons.

from classes import VoterList

def fraud_detect_bin(first_booth_voters, second_booth_voters):
    fraud = VoterList()
    comparisons = 0

    for i in range(0, len(second_booth_voters)):
        item = second_booth_voters[i]
        first = 0
        last = len(second_booth_voters) - 1

        while first &lt;= last:
            midpoint = (first + last) // 2

            if first_booth_voters[midpoint] == item:
            comparisons += 1
            fraud.append(first_booth_voters[midpoint])
            break 
        else:
            if item &lt; first_booth_voters[midpoint]:
                last = midpoint - 1
                comparisons += 2
            else:
                first = midpoint + 1
                comparisons += 2

    return fraud, comparisons
Don't use this, it's a redundant duplicate

for i in range(0, len(second_booth_voters)):
    item = second_booth_voters[i]


Instead use Python's for value in iterable syntax that lets you directly get the value of each list item for each iteration.

for item in second_booth_voters:


Also you should include a docstring.