I have been observing this strange behaviour for a while. Now I would like to know the reason.
See the example below.
Can someone explain why - and whether there are other options more similar to the first version that do what the second does.
>>> a
>>> [1, 0, 1, 1]
>>> for el in a:
el = 1
>>> a
>>> [1, 0, 1, 1]
>>> for i in range(len(a)):
a[i] = 1
>>> a
>>> [1, 1, 1, 1]