Q:

global/inner variable conflict? (python)

Sorry for the stupid question, I'm a newbie programmer. But can anyone tell me why the following program behaves this way?
def lol(a):
    a=[]
    a.append(1)
    return a

Now when I do 
k = [2, 3]
lol(k)

It returns 1, but k is still unchanged? Why?
Thanks a lot!

A:

In lol(a), the line a=[] binds a to a new list. After this line, a is no longer bounded to the same list than k. So what you're actually modifying in your function is a new list, not the list that you received in argument. For further information, see the docs.
If you want k to be [1], then you could write something like this instead:
def lol(a):
    a[:] = [1]
    return a

k = [2, 3]
lol(k) # now k is equal to [1]

