a =[1,2] for entry in a: entry = entry + 1 print a
Shouldn\'t the list be mutated to[2,3]? The result came out as [1,2]
[2,3]
[1,2]
No, why should it?
entry is just a name, which the for loop assigns to each integer in the list. If you subsequently reassign that name to point to a different integer, the list doesn't care.
entry