Because your On[-1]
and tempList
are the same object. And this is how it works with same objects:
>>> x=[1,2,3]
>>> y=x
>>> y.append(10)
>>> x
[1, 2, 3, 10]
>>> y
[1, 2, 3, 10]
>>>
4
solved Can Someone Explain What Just Happened (Python) [closed]