Problem With Python Lists and Object Reference
Till I know, virtually every item of data in a Python program is an object of a specific type or class. While performing m=300, the assignment to a variable creates an integer object with the value 300 and assigns the variable n to point to that object. If n=300 is also performed, both point to the same object. Sample Code : https://code.sololearn.com/cTW7Fyo7F0Eq/#py Now I saw some similar thing happening with lists. Same elements in a list point to the same object and in fact have a same index position. Sample Code : https://code.sololearn.com/cMvbNEvCfoGu/#py While I was performing a program in which all elements at even index location needs to be removed, I noticed that the 2nd index isn't present in the list. Index 1 and 2 have the same value i.e. 1 and both have the same index location i.e.1 and the element after it has an index value of 3. If I want to remove the element at 2nd index position then it's not possible here. Code : https://code.sololearn.com/c6F66H9v2nBz/#py Can anyone help ? How to solve this issue ?