This code:
def do_something(arg):
x=arg
x[0] = 9
return x
y = [1,2]
print "before: ", y
print "result of do_something(): ", do_something(y)
print "after: ", y
Results in this:
before: [1, 2]
result of do_something(): [9, 2]
after: [9, 2]
I dont get why the function changes the original lists that I pass? I even (try to) create a new copy of arg (x) to prevent it. Even if I dont return x, I still get the same result.