List unchanged in function--why?

Chris bit_bucket5 at
Mon Feb 18 11:38:13 EST 2002

This must have something to do with references etc, but I'm not sure
what's going on.

def changeList(theList):
  theList = ['a']

aList = ['x', 'y']
print aList
print aList

Running the above results in

['x', 'y']
['x', 'y']

Can someone explain?  I was expecting the second line printed to be


More information about the Python-list mailing list