I came across a error in my code and after searching found that the .pop() function changes a list value in a local function, on a global level, without using return function or global statement. I understand what pop does, I've used it before, but I don't understand why it's affecting the value of list globally. Why is that? Is there a name for this and are there other functions that does the same?
#Example code
listname=[1,2,3,4,5]
def checkpop(listname):
popped = listname.pop()
listname = ['WTF']
print (listname)
print(listname)
checkpop(listname)
print(listname)
OUTPUT
[1, 2, 3, 4, 5]
['WTF']
[1, 2, 3, 4]