0

I have the following code snippet in python 3.8 and Pycharm IDE:

def intersection(arr1, arr2):
    QuickSort(arr1, 0, len(arr1) - 1)
    QuickSort(arr2, 0, len(arr2) - 1)
    if len(arr1) > len(arr2):
        arr1, arr2 = arr2, arr1
    print("Swapped")

Python compiler shows me a warning, that says "shadows name arr1 from the outer scope", my question is: How do I tell python compiler that I am referring to arr1 from the outer scope?

  • 1
    `arr1` is one of the function's arguments, and as such will be treated as a local variable. – mportes Aug 19 '20 at 12:59
  • Normally, you could do `nonlocal arr1`, but that's not possible if `arr1` is the function's parameter (you will get `SyntaxError: name 'arr1' is parameter and nonlocal`). – mportes Aug 19 '20 at 13:36

0 Answers0