def test(list2):
list2.append(1)
print len(list2)
print len(LIST1)
LIST1 = [1]
while len(LIST1) < 9:
test(LIST1)
Please explain why 'LIST1' is increasing in size if I'm appending to 'list2', isn't variables inside functions local? And above all, how can I circumvent this?
The same happens if I make a new variable:
def test(arg_list):
list2 = arg_list
list2.append(1)
print len(list2)
print len(LIST1)
LIST1 = [1]
while len(LIST1) < 9:
test(LIST1)