'TypeError: unhashable type 'list' in instance method of python class

I was trying to perform Binary search using recursive function. I am facing issue while passing the half list after first match of middle element, getting 'unhashable type error for list'. Here is my code snippet.

class Solution:

    def search(self, nums: List[int], target: int) -> int:
        pivot = len(nums)//2
        if( nums[pivot] == target):
            return pivot
        
        elif( (len(nums) == 1) and (nums[pivot] != target) ):
            return -1
        
        elif(nums[pivot] < target):
            search(nums[pivot:], target)
            
        elif(nums[pivot] > target):
            search(nums[:pivot], target)

Error is occuring at line 10 (search(nums[pointer:], target)). Please ignore the error in logic: I was just trying to replicate the issue.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source