I am using Python 3. I am getting an unexpected result: a list is changing, but I do not understand how/where it changes. Here is my code:
def cool(goodlist, letter): goodlist.append("foobar") goodlist.append(letter) newlist = goodlist return newlist alista = [] var1 = cool(alista, "J") print(var1) print(alista)The above program prints out this:
Output:['foobar', 'J']
['foobar', 'J'][/font]
I would expect alista to be empty still. Why and what modifies alista?