Recursive function returning none?

You are ignoring the return values of recursive calls. You need to explicitly return those too:

elif input[mid] > target:
    return bisect(input[:mid], target)
elif input[mid] <= target:
    return bisect(input[mid:], target)

Recursive calls are just like any other function call; they return a result to the caller. If you ignore the return value and the calling function then ends, you end up with that calling function then returning None instead.

Leave a Comment