I've noticed that when you a run a list comprehension over a pre-existing list, the list is unchanged after the process.
Except, however, if the local names in the comprehension are the same is your initial variable.
Why is this?
Example:
>>> y=[1,2,3,4,5]
>>> [X**2 for X in y]
[1, 4, 9, 16, 25]
>>> y
[1, 2, 3, 4, 5]
>>> [y**2 for y in y]
[1, 4, 9, 16, 25]
>>> y
5
As you can see, in the second example, y
has been changed to the integer 5
.