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?
arr1is one of the function's arguments, and as such will be treated as a local variable.nonlocal arr1, but that's not possible ifarr1is the function's parameter (you will getSyntaxError: name 'arr1' is parameter and nonlocal).