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?

2
  • 1
    arr1 is one of the function's arguments, and as such will be treated as a local variable. Commented Aug 19, 2020 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). Commented Aug 19, 2020 at 13:36

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.