a = 1.111111
b = ["a", "b"]
def adder(x, y):
x = x *100000
y[0] = "Herman"
return x, y
print a
print b
print ""
adder(a,b)
print a # 1.111111 - has not updated
print b # ['Herman', 'b'] - has updated even if list is in gobal scope
Is Scope the same for lists and vars and other objects in Python? In the test above, the var a was not updated when I called/invoked the function adder, however, the list was updated. This would imply that global vars are not changeable from within functions, but that lists and other data container objects like dictionaries are.
Is that correct? Is there any easy way to model this idea in of scope mentally in my head?