0

Having trouble with my binary search where my comparison operators is arent working for when using data from my series, any ideas? Error is coming up on if el == value:

def binarySearch(elements, value):
left, right = 0, len(elements) - 1

while left <= right:
    middle = (left + right) // 2
    el = elements[middle]
    el = str(el)
    **if el == value:**
        return middle

    if elements[middle] < value:
        left = middle + 1
    elif elements[middle] > value:
        right = middle - 1
  • [Check this](https://stackoverflow.com/questions/53830081/python-pandas-the-truth-value-of-a-series-is-ambiguous) Hope this helps –  Jun 17 '21 at 16:43

0 Answers0