A
andrea crotti
Hi everbybody again,
I have a little "problem", I don't understand the reason of this:
a = [10,1,2,3]
def foo():
global a
for el in a:
el = el*2
This doesn't make any difference, if I do
def foo():
global a
a[0] = 4
But
def foo():
global a
for n in range(len(a)):
a[n] = a[n]*2
Doesn't work either...
So I think that's pretty weird, why this happen?
I have to create a new list and assign it back to get it working??
Thaks
I have a little "problem", I don't understand the reason of this:
a = [10,1,2,3]
def foo():
global a
for el in a:
el = el*2
This doesn't make any difference, if I do
def foo():
global a
a[0] = 4
But
def foo():
global a
for n in range(len(a)):
a[n] = a[n]*2
Doesn't work either...
So I think that's pretty weird, why this happen?
I have to create a new list and assign it back to get it working??
Thaks