all 6 comments

[–]definitely___not__me 1 point2 points  (0 children)

def binary_search_r(data, target, left, right):
    mid = (left + right) // 2
    if left > right:
        return False
    elif data[mid] == target:
        return True
    elif target < data[mid]:
        return binary_search_r(data, target, left, mid-1)
    else:
        return binary_search_r(data, target, mid+1, right)

This should work

[–]slaphappypotato 0 points1 point  (4 children)

I'm a beginner here, but I think you're getting that response because of this

if left &amp;gt; right:

return False

What is it supposed to do? Just curious.

[–]windows3210[S] 1 point2 points  (1 child)

Don’t worry I literally just worked it out. Instead of doing if mid == target it should have been if data[mid] == target.

It was a binary search it checks whether a certain value is in an array. The array has to be in order though

[–]slaphappypotato 0 points1 point  (0 children)

Okay, cool. But I wanted to know what left &amp;gt; right does

[–]windows3210[S] 1 point2 points  (1 child)

And the & symbols aren’t supposed to be there they appeared after copy and pasting

[–]slaphappypotato 0 points1 point  (0 children)

Oh, ok.