0

In my function, I only want to explicitly pass a single variable but It's being used twice. When I run the code, I get an error

def quickSort(arr, left=0, right=len(arr)-1):

NameError: name 'arr' is not defined

def quickSort(arr, left=0, right=len(arr)-1):
    # Base Case
    if left < right:
        pivotIdx = pivot(arr,left,right)
        # left side
        quickSort(arr, left, right=pivotIdx-1)
        # right side
        quickSort(arr, pivotIdx+1, right)
    return arr
arr = [4,8,2,1,5,7,6,3]
quickSort(arr)

How can i fix this?

Shadow Walker
  • 979
  • 5
  • 27
  • 51

0 Answers0