I ran this code on my local IDE and it returns a value. Leetcode keeps stating that there is no return value present regardless of input. I'm wondering what I'm missing. Language is Python3.
class Solution:
def search(self, nums: List[int], target: int, index = 0) -> int:
if len(nums) == 1:
if nums[0] == target:
return index
return -1
halfValue = len(nums)//2
firstHalf = nums[:halfValue]
secondHalf = nums[halfValue:]
if nums[halfValue] > target:
Solution.search(self, firstHalf, target, index)
elif nums[halfValue] < target:
index += halfValue
Solution.search(self, secondHalf, target, index)
elif nums[halfValue] == target:
return index + 1