So basically i've observed that in python3 if i do something like
a = 5
def addFive(x):
x+=5
return x
print(addFive(a),a)
The output will be "10 5" since a is not changed by the function. However the same does not happen for lists:
a = [1,2,3]
def b(x):
z = x
z.append(10)
b(a)
print(a)
When i run the function it changes the actual list.
Now to my Question: Why does this happen, where can i read up more about this(Honestly have no idea how to word my google search) and how can i avoid this. Please feel free to redirect me to other articles as this could be a common problem but I honestly couldn't find anything similar.
Thanks in advance :)