Just a simple code below:
import numpy as np
x=np.array([1,2])
y=[1,2]
L=1
def set_L(x,y,L):
x[0]+=1
y[0]+=1
L+=1
print(id(x))
print(id(y))
print(id(L))
I found that array x and list y is the same in the function set_L(), does this mean by default list and array are global variables? however variable L is not global in the function set_L(). I am confusing that why Python is designed like this?